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
Rhodochrosite | Level 12
%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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1165 views
  • 1 like
  • 7 in conversation