Hello,
I have a user defined macro variable as follows:
%let dfinactg='31jul2018'd;
data suivi;
set suivi;
attrib rundate format=ddmmyy10.;
rundate=%str(&dfinactg);
runyear=%sysfunc(year("&sysdate9"d));
run;
I want to reinsert this variable in the output dataset so I can refer to it in an excel file.
The issue is that the value gets interpreted as a date and when I concatenate it with text like this ="Situation: " & 'Raw Data'!$S$2 &" Broker" (where 'Raw Data'!$S$2 refers to a cell containing the value 07/31/2018 it converts this value to a datenumber.
To resolve this issue, I want to put a single apostrophe like this '07/31/2018 so excel is forced to interpret it as a string.
I haven't succeeded to do so in SAS
Best
I often use date literal expressions as macrovars, but don't include the quotes (whether double or single) in the value assigned to the macrovar. Instead
%let dfinactg=31jul2018;
Then you can
data suivi;
set suivi;
attrib rundate format=ddmmyy10.;
rundate="&dfinactg"d;
runyear=%sysfunc(year("&sysdate9"d));
run;
In other words, construct the user-defined macrovar dfinactg the same as the system defines variable sydate9.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.