将从输入 SAS 数据集生成 PDF/Excel/RTF 报告的 SAS 宏
SAS macro which will generate the PDF/Excel/RTF report from the input SAS dataset
需要 GENERIC SAS 宏来从输入 SAS 数据集生成 PDF/Excel/RTF 报告。
以下是要使用的参数---->
1) indsn – 输入数据集
2) varlist——要打印的变量列表。如果 none 则打印数据集中的所有变量
3) report_type – PDF 或 Excel 或 RTF。您需要使用适当的 ODS 语句。
4) title1——报告的标题1
5) footnote1 – 报告的脚注1
6) report_location – 报告的物理位置
请帮助我为上述问题建立逻辑???
尝试了多远:
data test;
input ID var1 var2 var3 var4;
cards;
1 6 4 4 5
6 5 4 5 5
3 7 9 5 9
7 9 4 8 6
运行;
ods pdf 文件='/folders/myfolders/v.pdf';
proc print data=work.test;
var ID; run;
ods pdf close;
%macro reportgen(indsn=,varlist=, report_type=, title1=, footnote=, report_location=);
%local i nextword; %let dsid =%sysfunc(open(&indsn));
%do i=1 %to %sysfunc(countw(&varlist));
%let nextword = %scan(&varlist, &i);
%end;
%mend reportgen;
%macro reportgen(indsn=work.test,varlist=var1 var2 var4,report_type=,title1=,footnote=,report_location);
这只是宏的一半。
首先,欢迎来到本站!
这是满足您需要的宏:
*ProcessBody;
%macro reportgen(indsn=,varlist=, report_type=, title1=, footnote1=, report_location=);
/* Windows related option */
goptions device=actximg;
/* Check if report path specified and abort gracefully if it isn't */
%if "&report_location"="" %then
%do;
data _NULL_;
putlog "ERROR: No destionation. Report aborted.";
RUN;
%GOTO done;
%end;
/* If varlist present, then keep only varlist */
%if &varlist ne %then
%do;
data tmp (keep= &varlist);
set &indsn;
run;
%let indsn=tmp;
%end;
/* Close all ODS destionations before oppening the one required */
ODS _ALL_ close;
ODS &report_type file="&report_location";
/* Specify Title and Footnote */
%if &title1 ne %then
%do;
title "&title1";
%end;
%if &footnote1 ne %then
%do;
footnote "&footnote1";
%end;
/* Print the output */
proc print data=&indsn;
run;
/* Completion */
ODS _ALL_ close;
%done:
%mend;
调用示例:
%reportgen(indsn=sashelp.class,varlist=name,report_type=RTF,title1=Hello World!,footnote1=Goodbye World!,report_location=/home/tmp/test.RTF);
需要 GENERIC SAS 宏来从输入 SAS 数据集生成 PDF/Excel/RTF 报告。
以下是要使用的参数---->
1) indsn – 输入数据集 2) varlist——要打印的变量列表。如果 none 则打印数据集中的所有变量 3) report_type – PDF 或 Excel 或 RTF。您需要使用适当的 ODS 语句。 4) title1——报告的标题1 5) footnote1 – 报告的脚注1 6) report_location – 报告的物理位置
请帮助我为上述问题建立逻辑???
尝试了多远:
data test;
input ID var1 var2 var3 var4;
cards;
1 6 4 4 5
6 5 4 5 5
3 7 9 5 9
7 9 4 8 6
运行;
ods pdf 文件='/folders/myfolders/v.pdf';
proc print data=work.test;
var ID; run;
ods pdf close;
%macro reportgen(indsn=,varlist=, report_type=, title1=, footnote=, report_location=);
%local i nextword; %let dsid =%sysfunc(open(&indsn));
%do i=1 %to %sysfunc(countw(&varlist));
%let nextword = %scan(&varlist, &i);
%end;
%mend reportgen;
%macro reportgen(indsn=work.test,varlist=var1 var2 var4,report_type=,title1=,footnote=,report_location);
这只是宏的一半。
首先,欢迎来到本站!
这是满足您需要的宏:
*ProcessBody;
%macro reportgen(indsn=,varlist=, report_type=, title1=, footnote1=, report_location=);
/* Windows related option */
goptions device=actximg;
/* Check if report path specified and abort gracefully if it isn't */
%if "&report_location"="" %then
%do;
data _NULL_;
putlog "ERROR: No destionation. Report aborted.";
RUN;
%GOTO done;
%end;
/* If varlist present, then keep only varlist */
%if &varlist ne %then
%do;
data tmp (keep= &varlist);
set &indsn;
run;
%let indsn=tmp;
%end;
/* Close all ODS destionations before oppening the one required */
ODS _ALL_ close;
ODS &report_type file="&report_location";
/* Specify Title and Footnote */
%if &title1 ne %then
%do;
title "&title1";
%end;
%if &footnote1 ne %then
%do;
footnote "&footnote1";
%end;
/* Print the output */
proc print data=&indsn;
run;
/* Completion */
ODS _ALL_ close;
%done:
%mend;
调用示例:
%reportgen(indsn=sashelp.class,varlist=name,report_type=RTF,title1=Hello World!,footnote1=Goodbye World!,report_location=/home/tmp/test.RTF);