/* Problem 1(a) */ proc contents data=sashelp.us_data out=mycontents noprint; run; data myvars; set mycontents(keep=NAME TYPE); run; data mynumvars; set myvars; IF TYPE=1; drop TYPE; run; *proc print data=mynumvars; *run; /* Problem 1(b) */ %macro dembplot(var,group=); proc sgplot data=sashelp.us_data; title "Boxplot of &var"; vbox &var /datalabel=statecode %if &group ne %then %do; category=&group %end; ; run; %mend; data _null_; set mynumvars; rc=dosubl(cats('%dembplot(',NAME,')')); run; /* Part (c) */ data _null_; set mynumvars; rc=dosubl(cats('%dembplot(',NAME,', group=region)')); run; /* Problem 2(a) */ DATA CTL2015; FILENAME webpage2 URL 'http://people.stat.sc.edu/hitchcock/tennissingleslists.txt'; INFILE webpage2 DLM='09'X firstobs=50 obs=102; INPUT Name :$24. Gender $ City :$10. State $ Rating $ RatingDate MMDDYY10. RatingType $; IF Rating=4.5 THEN NewDate = intnx('week',RatingDate,3,'same'); ELSE IF Rating=4.0 THEN NewDate = intnx('year',RatingDate,4,'same'); ELSE IF Rating=3.5 THEN NewDate = intnx('day',RatingDate,10,'same'); ELSE IF Rating=3.0 THEN NewDate = intnx('month',RatingDate,-2,'same'); ELSE IF Rating=2.5 THEN NewDate = intnx('quarter',RatingDate,1); run; proc print; VAR Name Rating RatingDate NewDate; format RatingDate NewDate mmddyy10.; run; /* Problem 2(b) */ data combined; do i=4,5; fname="/home/davidhitchcock/sasuser.v94/stat541/CTL201"||compress(put(i,1.)||".txt"); do until(lastobs); infile temp filevar=fname end=lastobs dlm='09'X ; INPUT Name :$24. Gender $ City :$10. State $ Rating $ RatingDate MMDDYY10. RatingType $; output; end; end; stop; run; /* Problem 2(c) */ DATA CTL2015more; FILENAME webpage3 URL 'http://people.stat.sc.edu/hitchcock/tennissinglesmore.txt'; INFILE webpage3 DLM='09'X; INPUT Name :$24. Gender $ City :$10. State $ Rating $ RatingDate MMDDYY10. RatingType $ MatchWins MatchLosses GameWins GameLosses; run; DATA CTL2015more; SET CTL2015more; GameWinPct=100*(GameWins/(GameWins+GameLosses)); MatchWinPct= 100*(MatchWins/(MatchWins+MatchLosses)); TotalMatches = MatchWins + MatchLosses; run; /* Problem 2(d) */ PROC SGPLOT DATA = CTL2015more; yaxis label="Total Matches Played"; vbar Rating / response=TotalMatches; run; /* Problem 2(e) */ PROC SGPANEL DATA = CTL2015more; PANELBY Rating; scatter x=GameWinPct y=MatchWinPct / group=Rating; TITLE 'Plots of MatchWinPct vs. GameWinPct, separately by Rating'; run;