Understanding DATA Step Code Requirements
Note the following requirements and information about using DATA step code to create a scenario:
- Specify the %EVENT macro call to enable the assignment of the standard scenario columns. Place this macro invocation within a conditional statement in your code where you want to write event data as output from the DATA step.
- Any DATA step that includes the
&CAPTURE_CHAR_VALUE, &MESSAGE, or &TRIG_TXNS variables must include the
LENGTH statement to specify the number of bytes for storing these variables. Here
is an
example:
LENGTH &CAPTURE_CHAR_VALUE VARCHAR(500) &MESSAGE VARCHAR(1024) &TRIG_TXNS VARCHAR(*);For more information, see LENGTH Statement in SAS DATA Step Statements: Reference.
IMPORTANT This requirement does not apply to the final DATA step (the DATA step that includes the &OUTPUT_DATASET variable). - If your DATA step code
contains subsetting IF statements, any records that do not meet a
specified condition are discarded during a scenario test. This means
that you will not see these records in the scenario test Records table.
To evaluate these records during the testing phase, you can include
a DO statement to retain the records.
For example, this sample code does not retain any records that do not meet the specified condition:
if height <= age <= weight; %EVENT;In contrast, this sample code does retain the records that do not meet the specified condition, but only for testing purposes; no events are generated for those records when the flow is run:
if height <= age <= weight then do; %EVENT; end; - If a scenario requires
more than one DATA step to achieve the desired output, you can include
sequential DATA steps in a single scenario. Note the following requirements
when using this model:
- The first DATA step
must contain the following code:
data sas_data_set; set &INPUT_DATASET; - The final DATA step
must contain the following code:
data &OUTPUT_DATASET; set sas_data_set; %EVENT;
- The first DATA step
must contain the following code:
- To reference a scenario
parameter, precede the parameter ID with an ampersand (&) and
do not enclose it in quotation marks.
Note: Though formatted similarly in SAS DATA step code, scenario parameters are not SAS macro variables and will not function as such. For example, prepending a scenario parameter with an additional ampersand will not resolve in the way that a SAS macro variable does.
- If you include comments in your DATA step code, do not include SAS keywords in a comment string. Examples of SAS keywords include DATA, DATASET, and SUM.
- For information about input and output, see the next topic, Working with DATA Step Scenario Input and Output.
Last updated: June 16, 2026