BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SasGuy614
Fluorite | Level 6

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 :Date 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;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

6 REPLIES 6
ballardw
Super User

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

   title "MTD_AS_OF_&Date.";

should work

SasGuy614
Fluorite | Level 6

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

SasGuy614
Fluorite | Level 6

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

ballardw
Super User

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

SasGuy614
Fluorite | Level 6

Thanks for your help again.

Hoffy
Calcite | Level 5

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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