The RUN statement in SAS is a crucial command that signals the end of a step in a SAS program, enabling the execution of the preceding code. It is essential for executing DATA and PROC steps and ensuring that processes are completed correctly.
The RUN statement serves as a delimiter in SAS programming, indicating that the code preceding it should be executed. This command is fundamental for both DATA steps—where data manipulation occurs—and PROC steps—where various procedures are applied to data.
In SAS, the RUN statement is typically placed at the end of a DATA step or a PROC step. Its syntax is simply:
RUN;
DATA example_data;
input name $ age;
datalines;
Alice 30
Bob 25
;
RUN;
In this example, the RUN statement executes the DATA step to create a dataset named example_data
.
PROC PRINT DATA=example_data;
RUN;
Here, the RUN statement executes the PROC PRINT step, which displays the contents of the example_data
dataset.
DATA new_data;
set example_data;
age_squared = age**2;
RUN;
PROC MEANS DATA=new_data;
VAR age_squared;
RUN;
In this example, each step is concluded with a RUN statement, ensuring each part is executed in sequence.
run;
, Run;
, and RUN;
are all valid.The RUN statement in SAS is essential for executing DATA and PROC steps, ensuring that the preceding code is completed before proceeding.