/*****************************************************/ /* STAT 330, Fall 2011 */ /* Homework 6 */ /*****************************************************/ options nocenter nodate nonumber pageno=1 pagesize=55 linesize=90; %let drive=C; /* 6.1.1 */ filename septW "&drive:\Classes\STAT 330\2011-4\Homework\September Weather.txt"; filename octW "&drive:\Classes\STAT 330\2011-4\Homework\October Weather.txt"; filename septM "&drive:\Classes\STAT 330\2011-4\Homework\Moon Sept 2010.csv"; filename octM "&drive:\Classes\STAT 330\2011-4\Homework\Moon Oct 2010.csv"; data sepWeather; infile septW dlm='09'x firstobs=3; informat highTime lowTime highWindTime time8.; input day meanTemp highTemp highTime lowTemp lowTime rain aveWind highWind highWindTime; month='SEP'; date = mdy(9,day,2010); run; data octWeather; infile octW dlm='09'x firstobs=3; informat highTime lowTime highWindTime time8.; input day meanTemp highTemp highTime lowTemp lowTime rain aveWind highWind highWindTime; month='OCT'; date = mdy(10,day,2010); run; data sepMoon; infile septM dsd; informat date ANYDTDTE9. percIllum comma7.; input date percIllum; month='SEP'; if date ^= .; run; data octMoon; infile octM dsd; informat date ANYDTDTE9. percIllum comma7.; input date percIllum; month='OCT'; if date ^= .; run; data allWeather; set sepWeather octWeather; run; data allMoon; set sepMoon octMoon; run; data all; merge allWeather (in=inWeather) allMoon (in=inMoon); by date; if inWeather and inMoon; run; proc means data=all n mean min max maxdec=2; var highTemp lowTemp; class month; run; proc print data=all; format date mmddyy8. highWindTime timeampm5.; var date highWind highWindTime; run; /* 6.2.2 */ libname dataLoc "&drive:\Classes\STAT 330\2011-4\Homework\"; filename readCSV "&drive:\Classes\STAT 330\2011-4\Homework\HOR2010.csv"; data contribs; infile readCSV dsd missover; informat name $50. contribs comma12. office $5. party $20. state $2. type $20. year $3.; input name contribs office party district state type year; run; /* data dataLoc.HOR2010; set contribs; run; */ proc freq data=contribs; tables office party state district type year; run; proc means data=contribs; var contribs; run; proc sort data=contribs; by year state district; run; data incumbents others; set contribs; if type="Incumbent" then output incumbents; else output others; run; proc means data=others nway noprint; var contribs; class year state district; output out=othersAve mean=mean sum=total; run; proc sort data=incumbents; by year state district; run; /* data dataloc.incumbents; set incumbents; run; data dataloc.others; set others; run; data dataloc.othersAve; set othersAve; run; */ data compare; merge incumbents (in=INincumb rename=(name=incumbName contribs=incumbCont party=incumbParty) drop=office type) othersAve (in=INothers rename=(mean=othersAveCont total=othersTotCont)); by year state district; if INincumb and INothers; diffAve = incumbCont - othersAveCont; diffTot = incumbCont - othersTotCont; run; /* data dataloc.compare; set compare; run; */ proc means data=compare; var diffAve diffTot; run; data findMax; set compare; if diffTot=4053086; run; proc means data=incumbents; var contribs; class party; run;