I have multiple datasets with different columns. Let us suppose dataset 1 has col1,col2,col3 whereas datsets 2 as col1 and col2 only.
Now I want to combine all these columns with a "," (comma).I have created a macro that will combine all the columns(col1,col2,col3) with a comma. But if there are less number of columns in another dataset there will be extra comma that I do not want.
For example if I write a code total=catx(col1,col2,col3) the result will be 1,2,
All i want is my result to be 1,2 with no extra commas
Kindly suggest me how to do this using a do loop.
Code
%macro xyz (data, data_1);
proc sort data =a.&data.;
by Type;
where Type ne " ";
run;
proc transpose data=a.&data. out=a.&data1.;
var string;
run;
data a.&data1.;
set a.&data1.;
total=catx(",",col1,col2,col3);
run;
%mend;
%xyz(gold,gold1);
%xyz(silver,silver1);
so if there are three variables in gol1 but 2 in silver1 on concatenating the total will give me a extra comma in the total variable which I do not require.I know because I have given a extra column(col3) in the catx statement so thats y it will give me extra comma but as I said different datasets different number of variables