Generate Code from Specifications

This article is currently being updated. Please come back later for updates.

Code generation converts the mapping logic in a specification into executable R, Python, or SAS programs. Generated programs are saved to the SCE folder defined in the specification and include the source dataset dependencies required to run each program in SCE.

Permissions: Users must have the required folder permissions for the Code Output Location folder in SCE to generate code.

Code Generation Prerequisites

Confirm the following before generating code:

  • The Output Language, Code Output Location, and Data Store fields are configured in the Code Generation section of the specification.
  • The mapping logic for each domain is complete, including the Source Table and Source Logic fields for the domain and the Source Field, Method Name, and Mapping Arguments values for each mapped variable.
  • The Code Output Location folder exists in SCE.
  • The source datasets referenced by the specification exist in SCE.
  • The domain is active. Code generation is not available for inactive domains.

Note: The Generate Code icon is enabled only when the specification is in a valid state to run. Validation checks run before code is generated to identify configuration and mapping issues early.

Configure Code Generation for a Specification

Code generation settings are defined in the Code Generation section of the Create Specification or Edit Specification window.

  1. Access Specifications from the Platform Menu under Metadata Management.
  2. Select the checkbox next to the specification.
  3. Click the Edit icon in the toolbar. The Edit Specification window opens.
  4. In the Code Generation section, configure the fields described in the following table.
  5. Click Save.
Code Generation section of the Edit Specification window with Output Language set to Python, a Code Output Location folder path, and Data Store set to SDTM
FIELD DESCRIPTION
Output Language The programming language of generated programs: Python, R, or SAS.
Code Output Location The SCE folder where generated programs are saved, for example, /eCS-DS-101/sdtm_auto/programs.
Data Store The data store where generated programs write output datasets.

Tip: Hover over the Info icon next to each field to view field guidance.

Important: Changing the Code Output Location after code is generated flags previously generated code as stale. Regenerate code to save updated programs to the new location.

Note: For details on all specification fields, refer to the Create and Manage Specifications article in the Specifications section.

Generate Code

Code can be generated for all domains in a specification or for selected domains. Real-time status displays at the domain level as code generates. If generation fails for one or more domains, the remaining domains continue processing.

Generate Code for All Domains in a Specification

  1. Access Specifications from the Platform Menu under Metadata Management.
  2. Select the checkbox next to the specification.
  3. Click the Generate Code icon in the toolbar. Code generation runs for all eligible domains in the specification.

Generate Code for Selected Domains

  1. From the Specifications list, click the hyperlinked Name of the specification. The Domains list opens.
  2. Select the checkbox next to each domain to generate.
  3. Click the Generate Code icon in the toolbar. The Code Generation and Output columns display a progress indicator for each selected domain until generation completes.

Note: Errors and issues reported during generation display in the Code Generation column. For details, refer to the View Code Generation Issues section in this article.

Review Code Generation Status

The Code Generation and Output columns in the Domains list display the status of the most recent code generation for each domain.

Domains list with Code Generation and Output columns showing a stale TI program, a DM program generated with issues, and AE and DD domains where code generation failed
COLUMN INDICATOR DESCRIPTION
Code Generation Progress indicator Code generation is in progress for the domain.
Code Generation Success indicator and program name The program generated successfully. The program name is a hyperlink that opens the program in the SCE Editor.
Code Generation Warning icon and program name The program generated, but issues were reported. Hover over the Warning icon to view the number of issues, or click the icon to open the Code Generation Issues window.
Code Generation Warning icon without a program name Code generation failed for the domain. Click the Warning icon to view the errors.
Code Generation Stale indicator The specification, domain, or variables changed after the code was generated. Hover over the stale indicator to view the tooltip, and regenerate the code to update the program.
Output Success indicator and dataset name The output dataset associated with the generated program is available in the configured data store.

View Code Generation Issues

  1. In the Domains list, hover over the Warning icon in the Code Generation column. A tooltip displays the number of reported issues, for example, ‘The program was generated with 3 issues. Click to view details.’
  2. Click the Warning icon. The Code Generation Issues window opens and displays the domain name, the number of issues, the generation date and time, and each reported issue.
  3. Review the issues, then click Close.
Code Generation Issues window for the DM domain listing three reported issues with the generation date and time and a Close button

Tip: Resolve reported issues in the domain or variable mapping logic, then regenerate the code.

Open a Generated Program in SCE

  1. In the Domains list, click the program name in the Code Generation column. The program opens in the SCE Editor.
  2. Review the comment block at the beginning of the program. The comment block includes the project, program name, author, build date, purpose, and a list of SCE dataset dependencies in load order.

SCE uses the dependency list in the comment block to resolve dependencies automatically during execution. In the Dependencies subpanel, hover over a dependency to view its path and the ‘Identified By: Code Generation’ source.

SCE Editor displaying the generated TI.py program with a header comment block listing SCE dataset dependencies and a Dependencies subpanel tooltip showing Identified By: Code Generation

Important: Each code generation run saves a new version of the program in SCE and replaces any manual edits made to the previous version. Previous versions remain available in the Versions subpanel.

Note: For details on working with programs, refer to the Use the Editor in the SCE article in the SCE section.

Identify and Update Stale Code

A stale indicator displays in the Code Generation column when previously generated code may be out of date. Code is flagged as stale when the specification, a domain, its variables, or the Code Output Location change after code is generated.

To update a stale program, regenerate code for the domain. For steps, refer to the Generate Code section in this article.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request