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;
%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;
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.
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!
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.