BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

  The macro variabe &&var&i. resolves to Bank, credit etc etc.
 
  There are attribute macros like %attrib_bank,%attrib_credit etc

I would like to the correct attribute based on the dataset name


Now is there a way how to append the &&var&i to %attrib_ so the correct attribute is passed based on &&var&i?


Example:
For i=1
&&var&i. resolves to Bank
data test_bank;
%attrib_??;-----The challenge is here, to execute %attrib_bank
run;

2 REPLIES 2
Reeza
Super User

%attrib_&&var&i. -> that doesn't work?

 


@SASPhile wrote:

  The macro variabe &&var&i. resolves to Bank, credit etc etc.
 
  There are attribute macros like %attrib_bank,%attrib_credit etc

I would like to the correct attribute based on the dataset name


Now is there a way how to append the &&var&i to %attrib_ so the correct attribute is passed based on &&var&i?


Example:
For i=1
&&var&i. resolves to Bank
data test_bank;
%attrib_??;-----The challenge is here, to execute %attrib_bank
run;


 

Tom
Super User Tom
Super User

Works fine for me.

%let i=1 ;
%let var1=bank;
%macro attrib_bank;
* part of a data step ;
%mend attrib_bank;

options mprint;
data test_bank;
  %attrib_&&var&i;
run;
17    data test_bank;
18      %attrib_&&var&i;
MPRINT(ATTRIB_BANK):   * part of a data step ;
19    run;

NOTE: The data set WORK.TEST_BANK has 1 observations and 0 variables.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 631 views
  • 0 likes
  • 3 in conversation