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.
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
select (srefmon);
when (1) output wave5sipp;
when (2) output wave6sipp;
otherwise;
end;
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.