Listing the observation using proc print!!!

                                  In this post we will see how to list the observations in a SAS data set using the PRINT procedure (PROC PRINT). Also we add some options and statements to this procedure to
allow you more control over what is displayed.

#Problem:

                                 We want to list first 10 observations in data set Blood. Include only the variables Subject, WBC (white blood cell), RBC (red blood cell), and Chol. Label the last three variables “White Blood Cells,” “Red Blood Cells,” and “Cholesterol,” respectively. Omit the Obs column, and place Subject in the first column.

Blood data set: https://www.dropbox.com/s/9wq9gdqk99981n3/blood.txt?dl=0

#Solution:


proc print data=learn.blood(obs=10) label;
id Subject;
var WBC RBC Chol;
label WBC = 'White Blood Cells'
RBC = 'Red Blood Cells'
Chol = 'Cholesterol';
run;

#Output:




#Explanation and learning:

                              In the proc print step we are saying to the SAS that print first 10 observation alone along with the labels. Also we make the subject as the first column by using ID keyword. By giving the label for each variable SAS print the label name instead of the variable name in the output.


No comments:

Post a Comment