Help using Base SAS procedures

SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

Reply
Regular Contributor
Posts: 190

SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset..,indsn – Input Dataset, varlist – List of Variables to be printed. If none then print all variables in the dataset,  report_type – PDF or Excel or RTF, title1 – Title1 of the report footnote1 – Footnote1 of the report report_location – Physical location of the report....

can u help me in building logic for this...?

Regular Contributor
Posts: 190

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset


Parameters to be used
1) indsn – Input Dataset
2) varlist – List of Variables to be printed. If none then print all variables in the dataset
3) report_type – PDF or Excel or RTF. You need to use appropriate ODS statements.
4) title1 – Title1 of the report
5) footnote1 – Footnote1 of the report
6) report_location – Physical location of the report
Super User
Super User
Posts: 7,401

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

So what is it "you" have done towards this, what is the "question" you are stuck on.  Much like the other posts, this is just a request for someone else to write the program for you.

Regular Contributor
Posts: 190

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

hello RW9 HNY,
macro to generate report in PDF,RTF,EXCEL FROM INPUT DATASET.....
Parameters to be used
1) indsn – Input Dataset
2) varlist – List of Variables to be printed. If none then print all variables in the dataset
3) report_type – PDF or Excel or RTF. You need to use appropriate ODS statements.
4) title1 – Title1 of the report
5) footnote1 – Footnote1 of the report
6) report_location – Physical location of the report.
this is my question..
am working on....
%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);
%if %sysfunc(varnum(&dsid,&nextword))> 0 %then %do;
%put Variable &nextword exists!;
%end;
%mend reportgen;
%macro reportgen(indsn=work.test, varlist=var1,var2,var4,report_type=,title,footnote,report_location);

am stuck here....reading d varlist but how can i incorporate rest of the variables if varlist empty & incorporate rest of the parameters in the code logic....
Regular Contributor
Posts: 190

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

indirectly need a generic macro to generate the PDF/Excel/RTF reports from the input SAS dataset???
Super User
Posts: 17,829

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

Why do you need to loop through the variable list? If you're using proc print you can use the macro variable directly. Otherwise, if it's empty you don't need a VAR statement because you're printing all the variables. Use that in your logic. I also don't see your report code, which is where you should start off from.
Regular Contributor
Posts: 190

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

hi reeza, i am using varlist to o/p only particular variables if the varlist is empty then all d variables from the dataset will be used in d report. & am not able to incorporate the ods code with my above mentioned macro so am asking for lil help... i went through various PDFS but no avail...
Regular Contributor
Posts: 190

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

how do i logic PDF/EXCEL/RTF ODS type in a generic macro.. so if report-type= pdf,rtf,excel.. i need to choose any one in my parameter & the report should b generated according to option..
Super User
Posts: 17,829

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

Occasional Contributor
Posts: 6

Re: SAS macro to generate the PDF/Excel/RTF report from the input SAS dataset

You can use the below logic to check the VAR Listed under VARS

 

%Macro ReportGen (indsn=DatasetName, Vars=);
	Proc print data = &DatasetName;
	%if &vars ne %then %do;
	VAR &Vars;
	%end;
	%else %do;
	%put no var specified !!;
	%End;
	Run;

%Mend ReportGen;

%ReportGen(Admit,)
%ReportGen(Admit, Name Gender)
Ask a Question
Discussion stats
  • 9 replies
  • 473 views
  • 0 likes
  • 4 in conversation