options nodate pagesize=54 linesize=80; /* Read in the input file */ data ex0107; * infile '../../../data/biostat/ex0107.dat'; infile 'C:\\biostat\\data\\ex0107.dat'; input trt otcm; length treatment $12.; if trt=1 then treatment='Streptomycin'; else if trt=2 then treatment='Control'; length outcome $5.; if otcm=1 then outcome='CI'; else if otcm=2 then outcome="MI"; else if otcm=3 then outcome="NID"; else if otcm=4 then outcome="MD"; else if otcm=5 then outcome="CD"; else if otcm=6 then outcome="Death"; run; /* Sort by trt and otcm to keep ordinal levels in table */ proc sort; by trt otcm; /* Obtain a crosstabulation of treatment and outcome */ proc freq order=data; tables outcome*treatment; run; /* Obtain side-by-side barplot (by treatment). */ proc chart; vbar outcome / group=treatment midpoints= "CI" "MI" "NID" "MD" "CD" "Death"; run; quit;