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;
The quotes around text involving macro variables need to be the double quote: "
title "MTD_AS_OF_&Date.";
should work
The quotes around text involving macro variables need to be the double quote: "
title "MTD_AS_OF_&Date.";
should work
Thanks a bunch, I didn't even think of that option.
Is there documentation that you can point me to on what the significance of using single vs double quotes.
I would start with the Macro Language Reference section, Understanding and Using the Macro Facility in the online help under Base SAS.
Thanks for your help again.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.