Using the sample data created by Patrick: data have_A; id=1; array Q3_ {5} 8. (5*2); array Q17_ {9} 8. (9*20); array Q41_ {10} 8. (10*1); array Q52_ {10} 8. (10*1); someOtherVar=0; output; run; data have_B; id=1; FirstName='fn'; LastName='ln'; Agency='A'; Status='1'; run; data want; merge have_a have_b; by id; run; proc sql noprint; select name into :q3 separated by ' ' from dictionary.columns where libname='WORK' and memname='WANT' and upcase(substr(name,1,3))='Q3_' order by name; select name into :q17 separated by ' ' from dictionary.columns where libname='WORK' and memname='WANT' and upcase(substr(name,1,3))='Q17' order by name; select name into :q41 separated by ' ' from dictionary.columns where libname='WORK' and memname='WANT' and upcase(substr(name,1,3))='Q41' order by name; select name into :q52 separated by ' ' from dictionary.columns where libname='WORK' and memname='WANT' and upcase(substr(name,1,3))='Q52' order by name; quit; data want; retain firstname lastname &q52 agency &q3 status &q52 &q41; set want(drop=id); run;
... View more