%macro trial(investor,type);
ODS TAGSETs.ExcelXP
options(sheet_interval='Table' sheet_name="&investor &type" center_horizontal="yes"
fittopage="No" blackandwhite="Yes" Embedded_Footnotes='Yes' Embedded_Titles='Yes'
autofit_height='Yes' orientation='landscape' absolute_column_width='7' Frozen_Headers='3');
proc report data=trial4 wrap style(column)={JUST=CENTER};
where investor = "&investor" and type = "&type";
columns LN_NO investor LM_TEMPLATE_NM s323_dt;
title justify=left "Report as of &rpt_dt";
FOOTNOTE1 justify=Left Height=8pt "&FNote1";
FOOTNOTE2 justify=Left Height=8pt "&FNote2";
RUN;
%mend;
%trial(FHA,IN TRIAL);
%trial(FHA,TRIAL ON STREET);
%trial(FHLMC,IN TRIAL);
%trial(FHLMC,TRIAL ON STREET);
%trial(FNMA,IN TRIAL);
%trial(FNMA,TRIAL ON STREET);
%trial(PRIVATE / REG AB,IN TRIAL);
%trial(PRIVATE / REG AB,TRIAL ON STREET);
For this report output the investor represents the example (ie FHA,FHLMC) and the Type is represented by examples (IN TRIAL or TRIAL ON STREET). Since this passes a macro and puts each in a separate tab based on the investor I want to show the s323_dt only if the Investor = ‘FHA’, not the others. I know I could create t separate dataset just for FHA however I want to handle this within the macro
columns LN_NO investor LM_TEMPLATE_NM
%if %upcase(&investor) = FHA %then s323_dt;
;
Note that there is NO ; on the line starting with "columns"
and the "extra" ; is actually there to close the statement starting with columns.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.