I've the macro variable as below. Now I want to create one more macro variable by using this macro variable 'Meta_Col' and I want to add the string meta. to the value in the macro variable Meta_Col
%let Meta_Col=businessDataName,reportingArea,reportingDate,reportingPurpose;
Desired Result is to create one macro variable (e.g. Meta_new_Col) and it should have value as below. Any help?
meta.businessDataName,meta.reportingArea,meta.reportingDate,meta.reportingPurpose
%let Meta_Col=businessDataName,reportingArea,reportingDate,reportingPurpose;
data _null_;
meta_col = "&meta_col.";
length meta_new_col $1000;
do i = 1 to countw(meta_col,",");
meta_new_col = catx(",",meta_new_col,"meta."!!scan(meta_col,i,","));
end;
call symputx("meta_new_col",meta_new_col);
run;
%put &=meta_new_col;
%let Meta_Col=businessDataName,reportingArea,reportingDate,reportingPurpose;
data _null_;
meta_col = "&meta_col.";
length meta_new_col $1000;
do i = 1 to countw(meta_col,",");
meta_new_col = catx(",",meta_new_col,"meta."!!scan(meta_col,i,","));
end;
call symputx("meta_new_col",meta_new_col);
run;
%put &=meta_new_col;
Alternatively, you can use a combination of functions:
%let Meta_new_Col=meta.%sysfunc(tranwrd(%quote(&meta_col),%str(,),%str(,meta.)));
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.