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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.