/* odshtmlfreq.sas Daniel Brockman 070519 Frequency output in html */
/* -------------------------------------------------------------- */
%macro odshtmlfreq(dsn=,vary=,style=WEB_7,file=) ;
/*
* dsn input data set
* vary name of a variable of dsn to graph
* style (ignored) SAS HTML style
* file (ignored) name of HTML file to write
*
* %odshtmlfreq uses proc freq to calculate the frequencies
* and ODS to capture output.
*
* 070523 Daniel Brockman. Moved ods html commands to caller.
*/
%global greturn;
%local t1 t2 i j k;
*ods html style=&style file=&file ;
* get temporary set names ;
%getdsname(dsn); %let t1 = &greturn;
%getdsname(dsn); %let t2 = &greturn;
data &t2 ; set &dsn ; if &vary ; run ; * remove missing obs ;
proc sort data=&t2 ; by &vary ; run ; * sort input ;
proc freq data=&t2 order=data noprint ; * compute frequencies ;
tables &vary / cumcol out=&t1 ; * output frequencies ;
run;
data &t2 ;
set &t1 ;
retain cumpct ;
if _N_ = 1 then cumpct = percent ;
else cumpct = percent + cumpct ; * calc cum pct ;
run ;
proc print data=&t2 ; * display frequencies;
run;
*ods html close;
title ; footnote ; * reinit ;
* remove tempo datasets;
%delds(&t1);
%delds(&t2);
%mend odshtmlfreq ;
/* -------------------------------------------------------------- */