The
data set Cert.Admit contains health information about patients in
a clinic, their activity level, height, and weight. Suppose you want
to create a subset of the data. Specifically, you want to create a
small data set containing data about all the men in the group who
are older than 50.
To create the data set, you must first reference the
library in which Cert.Admit is stored. Then you must specify the name
of the library in which you want to store the Males data set. Finally,
you add statements to the DATA step to read your data and create a
new data set.
The DATA step below
reads all observations and variables from the existing data set Cert.Admit
into the new data set Males. The DATA statement creates the permanent
SAS data set Males, which is stored in the SAS library Men50. The
SET statement reads the permanent SAS data set Cert.Admit and subsets
the data using a WHERE statement. The new data set, Males, contains
all males in Cert.Admit who are older than 50.
libname cert 'C:UsersStudent1cert';
libname Men50 'C:UsersStudent1certMen50';
data Men50.males;
set cert.admit;
where sex='M' and age>50;
run;
When you submit this
DATA step, the following messages appear in the log, confirming that
the new data set was created:
Log 4.3 SAS Log Output
69205 data Men50.males;
69206 set cert.admit;
69207 where sex='M' and age>50;
69208 run;
NOTE: There were 3 observations read from the data set
CERT.ADMIT.
WHERE (sex='M') and (age>50);
NOTE: The data set MEN50.MALES has 3 observations and 9
variables.
You can add a PROC PRINT
statement to this same example to see the output of Men50.Males.
proc print data=Men50.males;
title 'Men Over 50';
run;
Output 4.8 PROC PRINT Output for the Data Set Males