Since there is comma in the value as 'Age, Years', I suggest to change delimeter other than comma, for example, I use semi-comma in below codes: 1. add delimeter into quote function. 2. remove quote marks to call macro variables. *select names into a macro variable name_list;
*Select labels into a macro variable label_list;
proc sql noprint;
select quote(trim(name)||';') into :name_list separated by ' '
from sashelp.vcolumn
where libname='WORK' and memname='CLASS' and not missing (name);
select quote(trim(coalesce(label, name))||';') into :label_list separated by ' '
from sashelp.vcolumn
where libname='WORK' and memname='CLASS';
quit;
*check macro variables;
%put Name= &name_list;
%put;
%put Label= &label_list;
data _null_;
set class;
file fout dlm=';' dsd;
if _n_=1 then
do;
put &label_list;
put &name_list;
end;
put (_all_)(:);
run; Hope it will help
... View more