/* SAS programs consists of DATA statements to read and manipulate data, and PROC statements to run procedures on data. Statements end in a semicolon. Also, use a 'run ; ' statement at the end of each data or proc step. The INSIGHT module is recommended for data visualization. See the workshop material on INSIGHT at: http://www.uidaho.edu/stat/scc/wrkshp5.htm */ /* Three ways to read data into SAS */ /*1. Directly in the SAS program The INPUT statement tells SAS what the variable names are for each column of data, and a '$' following a variable names indicates that the variable is a character variable. */ data burgers ; input Name $ size_g totfat_g ; cards ; Hamb 107 9 Chsbrg 121 13 Delxbg 216 31 Fish 156 25 Chix 223 20 ; proc print ; run ; /* 2. In free format from an ASCII file */ data burgers2 ; infile 'c:\temp\burgs1.txt' firstobs=2 ; input name $ size totfat ; proc print data = hamburg ; run ; /*3. SAS program to read in a file in CSV (comma separated value) format. In the DATA step below, INFILE tells SAS to read an external file, DELIMITER tells SAS that data are separated by a comma, FIRSTOBS tells SAS to skip the first line in the file (which contains variable names). */ data students ; infile 'c:\temp\student2.csv' delimiter = ',' firstobs = 2 ; input sys1 sys2 sys3 dias1 dias2 dias3 pulse1 pulse2 pulse3 wt1 wt2 wt3 thumb $ finger eyecol $ height states ; run ; proc print data = students ; run ; proc means data = students ; var sys1 dias1 ; run ; proc plot data = students ; plot sys1*dias1 ; run ; proc freq data = students ; tables eyecol ; run ; proc freq data = students ; tables eyecol*thumb ; run ; proc sort ; by eyecol ; run ; proc means ; var sys1 dias1 ; by eyecol ; run ;