I am very new to SAS. Below is the code I used for an if then do statement, but I am getting a syntax error message for the "end;" statement:
DATA Temp_Data;
X2 = X1;
X3 =0
if missing(X2) then do;
X2 = 5;
X3 = 1;
end;
run;
The error message states:
"ERROR 22-322: Syntax error, expecting one of the following: ..........."
What am I doing wrong?
Please advise. Thanks.
You're missing a semicolon on the previous line.
Not sure what version of SAS you have but I get that error message directly:
126 DATA Temp_Data;
127 X2 = X1;
128 X3 =0
129 if missing(X2) then do;
--
79
ERROR 79-322: Expecting a ;.
130 X2 = 5;
131 X3 = 1;
132 end;
133 run;
NOTE: The SAS System stopped processing this step because of
errors.
WARNING: The data set WORK.TEMP_DATA may be incomplete. When
this step was stopped there were 0 observations and 3
variables.
NOTE: DATA statement used (Total process time):
real time 0.13 seconds
cpu time 0.01 seconds
You're missing a semicolon on the previous line.
Not sure what version of SAS you have but I get that error message directly:
126 DATA Temp_Data;
127 X2 = X1;
128 X3 =0
129 if missing(X2) then do;
--
79
ERROR 79-322: Expecting a ;.
130 X2 = 5;
131 X3 = 1;
132 end;
133 run;
NOTE: The SAS System stopped processing this step because of
errors.
WARNING: The data set WORK.TEMP_DATA may be incomplete. When
this step was stopped there were 0 observations and 3
variables.
NOTE: DATA statement used (Total process time):
real time 0.13 seconds
cpu time 0.01 seconds
Thank you Reeza,
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.