- SAS Macro to reduce coding- %include the program in the beginning
Functions List:
- help > help document for each function
- sumplot > plot graph sum(var) and group by variable
- sumtable > create table with count and sum figures
/*DanSASMacro*/
%macro sumplot(dataset,yaxis,xaxis,format);
%macro sumplottype(ind,sumformat);
proc sgplot data=&dataset;
title1 "Dataset : &dataset.";
title2 "Group by variable : &yaxis.";
title3 "&ind variable : &xaxis.";
hbar &yaxis. / stat=&ind. fill datalabel response=&xaxis.;
yaxis display=(nolabel noticks);
xaxis display=(nolabel);
&sumformat.;
run;
%mend;
%sumplottype(Freq);
%sumplottype(Sum,&format.);
%mend;
%sumplot(dataset,yaxis,xaxis,format xaxis dollar10.2);
%macro sumtable(dataset,yaxis,xaxis);
proc means data=&dataset. sum maxdec=1;
title1 "Dataset : &dataset.";
class &yaxis;
var &xaxis;
output out=&dataset._summtable sum = ;
run;
%mend;
%sumtable(dataset,yaxis,xaxis);
- help > help document for each function
- sumplot > plot graph sum(var) and group by variable
- sumtable > create table with count and sum figures
/*DanSASMacro*/
/*To develop global macro library and just include this program*/
%macro sumplot(dataset,yaxis,xaxis,format);
%macro sumplottype(ind,sumformat);
proc sgplot data=&dataset;
title1 "Dataset : &dataset.";
title2 "Group by variable : &yaxis.";
title3 "&ind variable : &xaxis.";
hbar &yaxis. / stat=&ind. fill datalabel response=&xaxis.;
yaxis display=(nolabel noticks);
xaxis display=(nolabel);
&sumformat.;
run;
%mend;
%sumplottype(Freq);
%sumplottype(Sum,&format.);
%mend;
%sumplot(dataset,yaxis,xaxis,format xaxis dollar10.2);
%macro sumtable(dataset,yaxis,xaxis);
proc means data=&dataset. sum maxdec=1;
title1 "Dataset : &dataset.";
class &yaxis;
var &xaxis;
output out=&dataset._summtable sum = ;
run;
%mend;
%sumtable(dataset,yaxis,xaxis);