/* senic3.sas */ %include '/home/u1407221/441s24/SAS02/senicread.sas'; title2 'Explore with Elementary tests'; proc corr; title3 'Correlations'; var census -- infpercent quality -- w; /* Equivalent to census nbeds nurses lngstay age xratio culratio infpercent quality mschool nc ne s w The nomiss option would yield casewise deletion of missing values. To get correlations of set A with set B, you could do something like proc corr; var a1 a2 a3; with b1 b2 b3 b4; */ /* proc plot is old fashioned -- line printer grahics! proc plot; title3 'Scatterplot'; plot quality * infpercent; */ proc sgplot; title3 'Scatterplot with least-squares line'; reg x=quality y=infpercent; proc sgscatter; title3 'Scatterplot matrix'; matrix census -- infpercent quality; proc sgplot; title3 'Number of beds and infection risk'; reg x=nbeds y=infpercent; proc sgplot; title3 'Number of beds and infection risk: By med school affiliation'; scatter x=nbeds y=infpercent / group = mdschl; /* Need ods graphics to set options (plotting symbols) */ ods graphics on / attrpriority=none; proc sgplot; /* With clearer plotting symbols */ title3 'Number of beds and infection risk: By med school affiliation'; styleattrs datasymbols=(Circle SquareFilled); scatter x=nbeds y=infpercent / group = mdschl ; run; ods graphics / reset; /* Tried Region and it was not useful */ proc corr; title3 'Just hospitals with med school affiliation'; where mdschl = 'Yes'; var nbeds infpercent; proc reg plots=none; /* Suppress diagnostic plots for now*/ title3 'Simple regression (One explanatory variable)'; model infpercent = nurses; /* Can do lots of analyses at once by giving a list of response variables. */ proc ttest; title3 'Less Risk at Hospitals with Med School Affiliation?'; class mdschl; var infpercent; proc freq; title3 'Relationship between region and medical school affiliation'; tables mdschl*region / norow nopercent chisq; /* Can do lots of analyses at once with syntax like tables (var1 var2 var3) * (item1-item15); */ proc freq; title3 'With expected frequencies'; tables mdschl*region / norow nopercent chisq expected; proc glm; title3 'Regional differences in average infection risk?'; class region; model infpercent = region; means region; /* Could get the means from proc means, with no extra boxplots */ proc means; class region; var infpercent; proc glm plots=none; title3 'Check regional differences in all quantitative variables'; class region; model census -- infpercent quality = region; means region; run;