/*****************************************************/ /* STAT 330, Fall 2011 */ /* Homework 2 */ /*****************************************************/ options nocenter nodate pageno=1 pagesize=55 linesize=100; /* 2.1.1 */ data movies; infile "C:\Classes\STAT 330\2011-4\homework\Box Office Sales 2.txt" firstobs=2; input rank 1-4 title $ 5-81 @82 sales comma14.; run; proc print data=movies; run; /* 2.1.2 */ data newBusinesses; infile "C:\Classes\STAT 330\2011-4\homework\SLO New Business Listing.txt" firstobs=3 truncover; input @1 busName $44. @45 busAddr $32. @77 busCityStateZip $38. @115 busPhone $10. @126 ownerLast $29. @155 ownerFirst $41. @196 busType $35.; run; proc print data=newBusinesses; run; /* 2.1.3 */ * http://www.cdc.gov/brfss/technical_infodata/surveydata/2010.htm; data brfss2010; infile "C:\Classes\STAT 330\2011-4\homework\BRFSS Subset.txt"; input smoke100 98 smokday2 99 stopsmk2 100 lastsmk1 101-102 usenow3 103 age 104-105; run; proc freq data=brfss2010; tables smoke100 smokday2 stopsmk2 lastsmk1 usenow3 age; run; /* 2.1.4 */ * http://www.txtdrop.com/abbreviations.php; data texting; infile "C:\Classes\STAT 330\2011-4\homework\Texting Abbreviations.txt" firstobs=2 missover truncover; input @1 abbrev $12. @14 meaning $50.; if meaning="" then delete; run; proc print data=texting; run; /* 2.1.5 */ * Read more: http://www.sacbee.com/statepay/?agency=LEGISLATURE-+SENATE#ixzz0z4QRmfcg; data senateSals; infile "C:\Classes\STAT 330\2011-4\homework\State Senate Salaries.txt" truncover; input name $40. / / agency $40. / / jobTitle $40. / / pay2010 comma12. / / pay2009 comma12. / / pay2008 comma12.; run; proc print data=senateSals; run; /* 2.2.1 */ libname saveLoc "G:\Classes\STAT 330\2011-4\Homework\"; filename readXLS dde "Excel|G:\Classes\STAT 330\2011-4\Homework\[College Rankings 2011.xlsx]National Universities!R2C1:R259C16"; data saveLoc.colleges; infile readXLS dlm='09'x notab dsd missover; informat school $70. percPell predGradRate actGradRate facAwards facNatAcads fedFunds percent4. resExpends comma6.; input rank school score percPell predGradRate actGradRate resExpends BA2PhD sciEngPhDs facAwards facNatAcads pcRank rotcRank fedFunds commServRank servFinAidRank; run; proc print data=saveLoc.colleges noobs; var rank school score resExpends; run; /* 2.2.2 */ data CAdeathRates; infile "G:\Classes\STAT 330\2011-4\Homework\AllCausesofDeath2008.csv" dlm=',' firstobs=2; informat county $30. target $2.; input county deathRate fieldRel fieldCat fieldRate target; run; proc print data=CAdeathRates; var county deathRate; run;