Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

Chapter 2. Getting Your Data into SAS® > Selected Informats - Pg. 49

Getting Your Data into SAS® 49 Example This example illustrates the use of informats for reading data. The following data file, Pumpkin.dat, represents the results from a local pumpkin-carving contest. Each line includes the contestant's name, age, type (carved or decorated), the date the pumpkin was entered, and the scores from each of five judges. Alicia Grossman 13 c 10-28-2003 7.8 6.5 7.2 8.0 Matthew Lee 9 D 10-30-2003 6.5 5.9 6.8 6.0 Elizabeth Garcia 10 C 10-29-2003 8.9 7.9 8.5 9.0 Lori Newcombe 6 D 10-30-2003 6.7 5.6 4.9 5.2 Jose Martinez 7 d 10-31-2003 8.9 9.510.0 9.7 Brian Williams 11 C 10-29-2003 7.8 8.4 8.5 7.9 7.9 8.1 8.8 6.1 9.0 8.0 The following program reads these data. Please note there are many ways to input these data, so if you imagined something else, that's OK. * Create a SAS data set named contest; * Read the file Pumpkin.dat using formatted input; DATA contest; INFILE 'c:\MyRawData\Pumpkin.dat'; INPUT Name $16. Age 3. +1 Type $1. +1 Date MMDDYY10. (Score1 Score2 Score3 Score4 Score5) (4.1); * Print the data set to make sure the file was read correctly; PROC PRINT DATA = contest; TITLE 'Pumpkin Carving Contest'; RUN; The variable Name has an informat of $16., meaning that it is a character variable 16 columns wide. Variable Age has an informat of three, is numeric, three columns wide, and has no decimal places. The +1 skips over one column. Variable Type is character, and it is one column wide. Variable Date