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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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