BookmarkSubscribeRSS Feed
RTelang
Fluorite | Level 6

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...?

9 REPLIES 9
RTelang
Fluorite | Level 6

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
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

RTelang
Fluorite | Level 6
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....
RTelang
Fluorite | Level 6
indirectly need a generic macro to generate the PDF/Excel/RTF reports from the input SAS dataset???
Reeza
Super User
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.
RTelang
Fluorite | Level 6
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...
RTelang
Fluorite | Level 6
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..
varunk
Calcite | Level 5

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)

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2158 views
  • 0 likes
  • 4 in conversation