*** use data available on web site; data c99; infile "f:\sasclass\data\cancer99.dat"; input (county gender age cause place) ($2. $1. 3. $4. $1.); run; ods trace on; title 'FULL OUTPUT FROM PROC UNIVARIATE WITH TRACE IN THE LOG'; proc univariate data=c99 plot; var age; id cause; run; ods trace off; ods trace on / listing; title 'FULL OUTPUT FROM PROC UNIVARIATE WITH TRACE ADDED TO LISTING'; proc univariate data=c99 plots; var age; run; ods trace off; *** use the names shown in the TRACE to limit the output; title 'PLOTS ONLY --- RESTRICTED OUTPUT FROM PROC UNIVARIATE (ODS SELECT...)'; proc univariate data=c99 plot; var age; ods select plots; run; *** create output for use in a document (RTF, rich text format); *** another way to select only a portion of the UNIVARIATE output; ods rtf file='z:\plots.rtf'; ods select plots; title 'RESTRICTED OUPUT FROM PROC UNIVARIATE(ODS SELECT...)'; proc univariate data=c99 plot; var age; id cause; run; ods select all; ods rtf close; *** add a BY-VARIABLE to UNIVARIATE; *** to use a BY-VARIABLE, sort the data; proc sort data=c99; by cause; run; *** names of various pieces of UNIVARIATE output in the LOG; ods trace on; title 'UNIVARIATE WITH A BY-VARIABLE'; proc univariate data=c99 plot; var age; by cause; *** limit causes, and ONLY FEMALES; where cause in: ('C18' 'C34' 'C50' 'C53' 'C56') and gender eq '2'; *** group CAUSE OF DEATH at the 3-digit level; format cause $3.; run; ods trace off; *** FYI: C18:COLON, C34:LUNG, C50:BREAST, C53:CERVICAL, C56:OVARIAN ; *** limit output to SIDE-BY-SIDE plots; proc format; value $can 'C18 '-'C189' = 'COLON' 'C34 '-'C349' = 'LUNG' 'C50 '-'C509' = 'BREAST' 'C53 '-'C539' = 'CERVICAL' 'C56 '-'C569' = 'OVARIAN' ; run; title 'AGE-AT-DEATH, 1999 FEMALE CANCER DEATHS'; proc univariate data=c99 plot; var age; by cause; *** limit causes, and ONLY FEMALES; where cause in: ('C18' 'C34' 'C50' 'C53' 'C56') and gender eq '2'; format cause $can.; ods select plots ssplots; run;