The below piece of code give me warning message.
I want to get rid of this warning, please suggest appropiate way to mask it.
%let k=XYZ.DT%DATE.;
data temp;
dsn="&k";
run;
If % is part of text, %nrstr is needed to mask it.
%let k=%nstr(XYZ.DT%DATE.);
data temp;
dsn="&k";
run;
You are calling a macro called DATE.
Does it exist and what does it do and what is the error message?
My string has % in the text. I am not calling any macro.
What's the message?
I bet it's WARNING: Apparent invocation of macro DATE not resolved. which is self explanatory really.
You need function %str() to use some characters in a macro value. Look it up.
I bet your log looks like this:
WARNING: Apparent invocation of macro DATE not resolved. 24 %let k=XYZ.DT%DATE.; 25 data temp; 26 dsn="&k"; WARNING: Apparent invocation of macro DATE not resolved. 27 run;
So what do you try to achieve by using the macro call(!) %date in the %let?
It's difficult to remove both warnings. The simplest way would be if you are allowed to change the value of your macro variable:
%let k='XYZ.DT%DATE.';
data temp;
dsn=&k;
run;
I am going to assume from your code there that DSN means that XYZ is the library name and DT%DATE. is the dataset name, and that your keeping this information for some reason. Personally I don't like data (dates in this case) in dataset names, as this complicates any further programming activity. I also question why you need a macro variable, and dataset to hold this information. Once you have created the libname referece XYZ then you will automatically have this information in sashelp.vtable, so you can simply your life by just doing:
libname xyz "..."; data temp; set sashelp.vtable (where=(libname="XYZ" and substr(name,1,2)="DT")); run;
All macro language is is a way to create Base SAS code, it is not a replacement for Base SAS.
%let k=%str(XYZ.DT%%DATE.); data temp; dsn=symget('k'); run; proc print; run;
How about this?
If % is part of text, %nrstr is needed to mask it.
%let k=%nstr(XYZ.DT%DATE.);
data temp;
dsn="&k";
run;
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.