Dear Experts,
I have been trying to run the simple SAS base program statement
data males sasuser.females;
Set sashelp.class;
If sex = 'M' then output males;
If sex = 'F' then output females;
Run;
proc print data = males;
var name age;
run;
proc print data = sasuser.females;
run;
please find the attached error ,could you please correct the mistake?
NOTE: SAS initialization used:
real time 0.97 seconds
cpu time 0.59 seconds
1 data males sasuser.females;
2 Set sashelp.class;
3 If sex = 'M' then output males;
4 If sex = 'F' then output females;
-------
455
ERROR 455-185: Data set was not specified on the DATA statement.
5 Run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MALES may be incomplete. When this step was stopped there were 0
observations and 5 variables.
WARNING: The data set SASUSER.FEMALES may be incomplete. When this step was stopped there
were 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
6 proc print data = males;
7 var name age;
8 run;
NOTE: No observations in data set WORK.MALES.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
9 proc print data = sasuser.females;
10 run;
NOTE: No observations in data set SASUSER.FEMALES.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
Regards,
Rakesh
See something not quite the same here?
1 data males sasuser.females;
2 Set sashelp.class;
3 If sex = 'M' then output males;
4 If sex = 'F' then output females;
BTW using the SASUSER library is often not the best idea as SAS uses that library and contents may be affected by upgrades and/or reinstallation. If you want a permanent library assign your own so that you have control over where it is and what happens.
A single-stage dataset name will always point to WORK (or USER, if such a library is defined). Therefore female is taken as WORK.FEMALE, and is different from SASUSER.FEMALE. You just need to be consistent in naming your datasets in the data and output statements.
See something not quite the same here?
1 data males sasuser.females;
2 Set sashelp.class;
3 If sex = 'M' then output males;
4 If sex = 'F' then output females;
BTW using the SASUSER library is often not the best idea as SAS uses that library and contents may be affected by upgrades and/or reinstallation. If you want a permanent library assign your own so that you have control over where it is and what happens.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.