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

Hi,

I am trying to use a macro in the table name but its not recognizing. Am I doing anything wrong?

Data test;

Set acc_&max_acc;

run;

Max_acc is macro with value 12.

Sachin

1 ACCEPTED SOLUTION

Accepted Solutions
kuridisanjeev
Quartz | Level 8

Yes,My Guess is Correct.

Macro variable containing Leading balnks

here is the solution to avoid these type of error,

Data a;

set acc%sysfunc(trim(&max_acc));

run;



Regards,


Sanjeev.K

View solution in original post

5 REPLIES 5
kuridisanjeev
Quartz | Level 8

Hi Sachin,

May i know what error you are getting .

I guess That variable containing leading blanks.

Regards,

Sanjeev.K

sachin01663
Obsidian | Level 7

I think you are right Sanjeev. I am getting this error:

NOTE: Line generated by the macro variable "MAX_ACC".

392   acc_      12

                --

                22

ERROR: File WORK.ACC_.DATA does not exist.

There are some leading blanks before 12 so its not recognizing table name - its reading table name till Acc_.

However, I used SQL INTO: to create this macro and its numeric - so how come there are leading blanks

Thanks

Sachin

kuridisanjeev
Quartz | Level 8

Yes,My Guess is Correct.

Macro variable containing Leading balnks

here is the solution to avoid these type of error,

Data a;

set acc%sysfunc(trim(&max_acc));

run;



Regards,


Sanjeev.K

kuridisanjeev
Quartz | Level 8

Hi Sachin,

Basically Macro concept is Text Substitution.So what ever the value you going to store in a macro variable ,it always stores as a text only.

Regards,

Sanjeev.K

sachin01663
Obsidian | Level 7

Thank you Sanjeev. Very Helpful.

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
  • 5 replies
  • 4326 views
  • 3 likes
  • 2 in conversation