The SAS Output Delivery System and reporting techniques

Passing a numeric variable macro to a proc print title within ODS

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

Passing a numeric variable macro to a proc print title within ODS

I have a numeric value that represents a date in a date table that I created (below). What I would like to do is pass this variable to the title option within proc print.I have pasted the code below but I can't seem to get it to work correctly. When the query is executed, I receive no errors, however the title shows the macro name and not the variable that I am trying to pass. I did some research and read about the #BYVAR #BYVAL but I don't believe these are a valid option because the variable that I am trying to pass along isn't in the dataset used for the proc print. Any help/suggestions would be appreciated.


/*Date Table*/

YYYYMMDD
20150623

/*Macro for getting the most recent date in the date table*/

proc sql noprint; select YYYYMMDD into Smiley Very Happyate from Datetable where row = 1;

%let Date = &Date.;

/*Report*/

ods tagsets.excelxp options(sheet_interval='none' sheet_name = 'MTD' );

proc print

    data = Final.MTD_&Date. noobs label

    style(header)=[just=c];

    sum   

        CHK_TTL

        PCA

        __FREE

        HUN5

        HUN25

        ESTATE_CHK

        CHK_OTHER

        SAV

        MMA

        TIME;

    var AREA / STYLE(COLUMN)=[CELLWIDTH=250];

    var CHK_TTL / STYLE(COLUMN)=[CELLWIDTH=100];

    var PCA / STYLE(COLUMN)=[CELLWIDTH=100];

    var __FREE / STYLE(COLUMN)=[CELLWIDTH=100];

    var HUN5 / STYLE(COLUMN)=[CELLWIDTH=100];

    var HUN25 / STYLE(COLUMN)=[CELLWIDTH=100];

    var ESTATE_CHK / STYLE(COLUMN)=[CELLWIDTH=100];

    var CHK_OTHER / STYLE(COLUMN)=[CELLWIDTH=100];

    var SAV / STYLE(COLUMN)=[CELLWIDTH=100];

    var MMA / STYLE(COLUMN)=[CELLWIDTH=100];

    var TIME / STYLE(COLUMN)=[CELLWIDTH=100];

    label

        Area = 'Region'

        CHK_TTL = '# of Chk. Accts'

        __FREE = '* FREE'

        ESTATE_CHK = 'Estate Chk.'

        CHK_OTHER = 'Chk. Other';

    title 'MTD_AS_OF_&Date.';

run;


Accepted Solutions
Solution
‎06-25-2015 10:59 AM
Grand Advisor
Posts: 10,211

Re: Passing a numeric variable macro to a proc print title within ODS

The quotes around text involving macro variables need to be the double quote: "

   title "MTD_AS_OF_&Date.";

should work

View solution in original post


All Replies
Solution
‎06-25-2015 10:59 AM
Grand Advisor
Posts: 10,211

Re: Passing a numeric variable macro to a proc print title within ODS

The quotes around text involving macro variables need to be the double quote: "

   title "MTD_AS_OF_&Date.";

should work

Contributor
Posts: 29

Re: Passing a numeric variable macro to a proc print title within ODS

Thanks a bunch, I didn't even think of that option.

Contributor
Posts: 29

Re: Passing a numeric variable macro to a proc print title within ODS

Is there documentation that you can point me to on what the significance of using single vs double quotes.

Grand Advisor
Posts: 10,211

Re: Passing a numeric variable macro to a proc print title within ODS

I would start with the Macro Language Reference section, Understanding and Using the Macro Facility in the online help under Base SAS.

Contributor
Posts: 29

Re: Passing a numeric variable macro to a proc print title within ODS

Thanks for your help again.

Occasional Contributor
Posts: 9

Re: Passing a numeric variable macro to a proc print title within ODS

You did get the correct answer to your question.  I noticed some code you don't really need.

The %let Date=&Date; isn't needed as that is what the proc sql execution just above it does.  That syntax creates the macro date with the contents of YYYYMMDD.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 575 views
  • 0 likes
  • 3 in conversation