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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
slchen
Lapis Lazuli | Level 10

If % is part of text, %nrstr is needed to mask it. 

%let k=%nstr(XYZ.DT%DATE.);
data temp;
dsn="&k";
run;

 

View solution in original post

8 REPLIES 8
ChrisNZ
Tourmaline | Level 20

You are calling a macro called DATE.

Does it exist and what does it do and what is the error message?

RahulG
Barite | Level 11

My string has % in the text. I am not calling any macro.

ChrisNZ
Tourmaline | Level 20

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.

 

See rules #1 and #2.

 

Kurt_Bremser
Super User

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?

Astounding
PROC Star

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;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

WarrenKuhfeld
Ammonite | Level 13
%let k=%str(XYZ.DT%%DATE.);
data temp;
dsn=symget('k');
run;
proc print; run;

How about this?

slchen
Lapis Lazuli | Level 10

If % is part of text, %nrstr is needed to mask it. 

%let k=%nstr(XYZ.DT%DATE.);
data temp;
dsn="&k";
run;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 8 replies
  • 1666 views
  • 1 like
  • 7 in conversation