SAS author's tip: Using PROC PRINT to list observations in a data set

1

This week's SAS tip is from A. John Bailer and his book Statistical Programming in SAS. A Fellow of the American Statistical Association, John has been using SAS for 30 years. He's also Distinguished Professor and Chair of the Department of Statistics at Miami University. To read a free chapter and user reviews of John's book, visit his author page.

The following excerpt is from SAS Press author John Bailer's book "Statistical Programming in SAS" Copyright © 2010, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software) 

3.6  Using PROC PRINT to List the Observations in a Data Set

After you input, infile, or import a data set and define labels and formats, you typically want to look at the observations and variables of the data set that you constructed. PROC PRINT displays the observations in a SAS data set. This display can be modified to calculate simple statistics such as sums, and it can use variables to identify observations in the listing. The following partial SAS code prints the nitro_tox data set grouped by concentration (by conc), sums the total number of young produced in each concentration condition (sum total), and uses the animal ID to identify each observation (id animal):

proc print data=nitro_tox;
by conc; *  assumes input data sorted by this variable;
sum total;
id animal;*  animal number used to ID case;
run;

This code produces the printout in Display 3.14. Even though cbrood3 is a numeric variable, it is displayed using the format that has been assigned to it.

 

 

Share

About Author

Shelly Goodin

Social Media Specialist, SAS Publications

Shelly Goodin is SAS Publications' social media marketer and the editor of "SAS Publishing News". She’s worked in the publishing industry for over thirteen years, including seven years at SAS, and enjoys creating opportunities for fans of SAS and JMP software to get to know SAS Publications' many offerings and authors.

Related Posts

Back to Top