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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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