Posted by : Netbloggy Saturday, September 19, 2015

PROC PRINT in SAS has a lot of options which can help us tweak the way we display our data.

Options like n = caption of summary, firstobs = no. of first observations & obs = last observation to be processed.

Problem 1:

List the first 6 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. Be sure the column
headings are the variable labels, not the variable names.

Solution: 

 
proc print data=A15001.A01_Blood 
			(obs=6) 
			n = 'No. of Observations = '
			label; /* printing only 6 obs */
	label WBC = 'White Blood Cells'
		RBC = 'Red Blood Cells'
			Chol = 'Cholesterol';
		ID Subject;	 /* omit obs & place the id variable at first */
		var WBC RBC Chol;
run;
 

Output:
Learning:

  1. Different options of PROC PRINT

Problem 2:

List the four observations from data set Blood (3-6). Also group the output report by
BloodType.

Solution:

/* sorting before using grouping in PROC PRINT */
proc sort data=A15001.A01_Blood; by BloodType; run;
 
proc print data=A15001.A01_Blood 
			(firstobs=3 obs=6) /* printing only 4 obs */
			n = 'No. of Observations = '; 
	 	by BloodType;
		ID Subject;	 /* omit obs & place the id variable at first */
		var WBC RBC Chol;
run;
 

Output:


Learning:

  1. Using BY to group the output in PROC PRINT
  2. Using FirstObs to select a start point while displaying the output

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

- Copyright © nulldata -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -