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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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