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

I am trying to add a column named "ADM_YN" to an existing data set. 

When I input:

data=DID.MLIP101;
set=DID.MLIP1;
IF Antidepressants__ gt 0 THEN ADM_YN= "y";
IF Antidepressants__= 0 THEN ADM_YN= "n";
run;

 

I get this error for every line:

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

What am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Code should be:

data   DID.MLIP101;
  set   DID.MLIP1;
         IF Antidepressants__   gt 0 THEN ADM_YN= "y";
         IF Antidepressants__    = 0 THEN ADM_YN= "n";
run;

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

Code should be:

data   DID.MLIP101;
  set   DID.MLIP1;
         IF Antidepressants__   gt 0 THEN ADM_YN= "y";
         IF Antidepressants__    = 0 THEN ADM_YN= "n";
run;
novinosrin
Tourmaline | Level 20

HI @dkeine  Welcome to the SAS forum. In addition to the correction you received , since your conditions are mutually exclusive, you are better off adding a else if

 

data   DID.MLIP101;
  set   DID.MLIP1;
         IF Antidepressants__   gt 0 THEN ADM_YN= "y";
         else IF Antidepressants__    = 0 THEN ADM_YN= "n";/*else if*/
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 590 views
  • 0 likes
  • 3 in conversation