BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
murad130
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

2 REPLIES 2
Reeza
Super User

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

murad130
Calcite | Level 5

Thank you Reeza,

This was very helpful!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1412 views
  • 2 likes
  • 2 in conversation