BookmarkSubscribeRSS Feed
npa
Calcite | Level 5 npa
Calcite | Level 5
It's been awhile since I used macros, but I recall there was a way to alter a variable or dataset name.

For example, I am using the following statement:

%macro loc(position);
.
.
proc print data=&position out=&position_t;
.
.
%mend loc;
%position(xyz)

I want dataset xyz to be read in, and I want to output the dataset xyz_t. I feel like maybe I have to put quotes around it or something, but don't recall exactly. Does anyone know what is the proper syntax to name the dataset xyz_t?
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi! Remember that you need to provide a way for the macro processor to tell when the end of the macro variable name has been reached. so if you had this:

&lib..&dsn

then the first . will signal the end of &lib and the second . will be inserted after &lib resolves. so if &lib is SASHELP and &dsn is CLASS then

&lib..&dsn would resolve to SASHELP.&dsn which would resolve to SASHELP.CLASS

So in your case, you should do:

&position._t

also, you were probably typing fast, but I thought, just in case, I'd mention that since your macro statement has
%macro LOC(position), then the correct invocation would be:

%loc(xyz)

good luck,
cynthia
npa
Calcite | Level 5 npa
Calcite | Level 5
That's it. Thanks for the help. You're right. I was typing fast.

Thanks!

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 657 views
  • 0 likes
  • 2 in conversation