title "Body Fat Data"; data bodyfat; input age pctfat sex $; datalines; 23 9.5 M 23 27.9 F 27 7.8 M 27 17.8 M 39 31.4 F 41 25.9 F 45 27.4 M 49 25.2 F 50 31.1 F 53 34.7 F 53 42.0 F 54 29.1 F 56 32.5 F 57 30.3 F 58 33.0 F 58 33.8 F 60 41.1 F 61 34.5 F ; run; * Check the data 'bodyfat' at Work/Bodyfat (use Explorer) ; proc print data=bodyfat; run; proc corr data=bodyfat; run; proc corr data=bodyfat spearman pearson; run; title "Reading Data"; data slimmingclub; /* list input */ infile 'C:\Users\sungkyu\Dropbox\Teaching\1301-StatisticalPackages\datasets\slimmingclub.dat'; input idno team $ startweight weightnow; run; * Check the data 'slimmingclub' at Work/Slimmingclub (use Explorer) Compare with the raw data 'slimmingclub.dat' ; data slimmingclub2; /* column input */ infile 'C:\Users\sungkyu\Dropbox\Teaching\1301-StatisticalPackages\datasets\slimmingclub2.dat'; input name $ 1-18 team $ 20-25 startweight 27-29 weightnow 31-33; run; data slimmingclub3; /* formatted input */ infile 'C:\Users\sungkyu\Dropbox\Teaching\1301-StatisticalPackages\datasets\slimmingclub2.dat'; input name $19. team $7. startweight 4. weightnow 3.; run; * check that SAS data sets 'slimmingclub2' and 'slimmingclub3' are identical. ; * Open the SAS data set 'slimmingclub2' (or 'slimmingclub3') Right-click on any variable name (which will highlight the entire column), then from the pop-up menu, choose 'Column Attributes' See how the Informat is similar to and different from the informat we used in the data step. ; data slimmingclub4; /* formatted input */ infile 'C:\Users\sungkyu\Dropbox\Teaching\1301-StatisticalPackages\datasets\slimmingclub2.dat'; input @20 team $7. startweight 4. weightnow 3.; /* optionally proceded by @startingcolumn */ run; title "Modifying Data"; data temp; set bodyfat; nonfat = 100 - pctfat; nonfat = nonfat / 100; nationality = 'US'; drop age sex; if pctfat > 30 then high = 1; else high = 0; run; data bodyfatmen; set bodyfat; where sex = 'M'; run; data bodyfatwomen; set bodyfat; where sex = 'F'; if pctfat > 30 then delete; run; data bodyfat2; set bodyfatmen bodyfatwomen; run; title "Storing/Loading SAS Data Sets on Disk "; libname db "C:\Users\sungkyu\Dropbox\Teaching\1301-StatisticalPackages\SASexercises"; data db.slimmingclub; set slimmingclub; run; data slimmingclub; set db.slimmingclub; run; title "Statistical Graphics"; proc sgplot data=bodyfat; scatter y=pctfat x=age; run; proc sgplot data=bodyfat; scatter y=pctfat x=age /group=sex; run; proc sgplot data=bodyfat; scatter y=pctfat x=age /group=sex; reg y=pctfat x=age /nomarkers; loess y=pctfat x=age / nomarkers; run; title "ODS"; ods rtf file = "C:\Users\sungkyu\Dropbox\Teaching\1301-StatisticalPackages\SASexercises\bodyfat.rtf"; proc sgplot data=bodyfat; scatter y=pctfat x=age; run; proc corr data=bodyfat; run; ods rtf close;