BookmarkSubscribeRSS Feed
Mike7
Calcite | Level 5


proc sort data = waves;
by ssuid eentaid epppnum srefmon;
run;

data
wave5sipp
(rename = (tage=tage1
tptotinc=ptotinc1
srefmon=srefmon1 ))
wave6sipp
(rename =(tage=tage2
tptotinc=ptotinc2
srefmon=srefmon2 ));
set waves;
select (srefmon);
when (1) output wave5sipp;
when (2) output wave6sipp;
end;
run;

 

log message:

 

ERROR: Unsatisfied WHEN clause and no OTHERWISE clause at line 2120 column 5.
SSUID=019128000932 SWAVE=5 SREFMON=3 RHCALMN=5 SHHADID=11 TFIPSST=22
THOTHINC=0 RFID=3 RFNKIDS=0 RFOKLT18=0 EENTAID=11 EPPPNUM=101 ESEX=2 ERACE=1
EORIGIN=2 TAGE=47 ERRP=6 EMS=4 ETYPMOM=-1 ETYPDAD=-1 TPEARN=2800
TPTOTINC=2800 RENROLL=3 EEDUCATE=37 EJBHRS1=40 _ERROR_=1 _N_=5
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 5 observations read from the data set WORK.WAVES.
WARNING: The data set WORK.WAVE5SIPP may be incomplete. When this step was
stopped there were 2 observations and 25 variables.
WARNING: Data set WORK.WAVE5SIPP was not replaced because this step was
stopped.
WARNING: The data set WORK.WAVE6SIPP may be incomplete. When this step was
stopped there were 2 observations and 25 variables.
WARNING: Data set WORK.WAVE6SIPP was not replaced because this step was
stopped.

3 REPLIES 3
art297
Opal | Level 21

add an otherwise; clause to your select statement.

 

Ref: Null statements that are used in OTHERWISE statements prevent SAS from issuing an error message when all WHEN conditions are false.

 

Art, CEO, AnalystFinder.com

 

PGStats
Opal | Level 21
select (srefmon);
when (1) output wave5sipp;
when (2) output wave6sipp;
otherwise;
end;
PG
Reeza
Super User

What do you want your code to do when SREFMON=3 in the 5th record? Currently this is causing your error, because it's not included in your SELECT statement, but you should deal with it explicitly IMO. If you had used IF/THEN it would not have errored but would have set the value to missing. It's good to note the difference between these methods of recoding data.

 

 

PS. In real life, make sure that you can post your errors because they may contain confidential information. Since this is homework I assume there's no issue with your data here. 

 

ERROR: Unsatisfied WHEN clause and no OTHERWISE clause at line 2120 column 5.
SSUID=019128000932 SWAVE=5 SREFMON=3 RHCALMN=5 SHHADID=11 TFIPSST=22
THOTHINC=0 RFID=3 RFNKIDS=0 RFOKLT18=0 EENTAID=11 EPPPNUM=101 ESEX=2 ERACE=1
EORIGIN=2 TAGE=47 ERRP=6 EMS=4 ETYPMOM=-1 ETYPDAD=-1 TPEARN=2800
TPTOTINC=2800 RENROLL=3 EEDUCATE=37 EJBHRS1=40 _ERROR_=1 _N_=5

 

 

 

 


@Mike7 wrote:


proc sort data = waves;
by ssuid eentaid epppnum srefmon;
run;

data
wave5sipp
(rename = (tage=tage1
tptotinc=ptotinc1
srefmon=srefmon1 ))
wave6sipp
(rename =(tage=tage2
tptotinc=ptotinc2
srefmon=srefmon2 ));
set waves;
select (srefmon);
when (1) output wave5sipp;
when (2) output wave6sipp;
end;
run;

 

log message:

 

ERROR: Unsatisfied WHEN clause and no OTHERWISE clause at line 2120 column 5.
SSUID=019128000932 SWAVE=5 SREFMON=3 RHCALMN=5 SHHADID=11 TFIPSST=22
THOTHINC=0 RFID=3 RFNKIDS=0 RFOKLT18=0 EENTAID=11 EPPPNUM=101 ESEX=2 ERACE=1
EORIGIN=2 TAGE=47 ERRP=6 EMS=4 ETYPMOM=-1 ETYPDAD=-1 TPEARN=2800
TPTOTINC=2800 RENROLL=3 EEDUCATE=37 EJBHRS1=40 _ERROR_=1 _N_=5
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 5 observations read from the data set WORK.WAVES.
WARNING: The data set WORK.WAVE5SIPP may be incomplete. When this step was
stopped there were 2 observations and 25 variables.
WARNING: Data set WORK.WAVE5SIPP was not replaced because this step was
stopped.
WARNING: The data set WORK.WAVE6SIPP may be incomplete. When this step was
stopped there were 2 observations and 25 variables.
WARNING: Data set WORK.WAVE6SIPP was not replaced because this step was
stopped.


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 5152 views
  • 2 likes
  • 4 in conversation