I recommend just using PROC APPEND, but assuming you only have dataset B you can use that to generate a LENGTH statement. proc sql noprint ; select catx(' ',name,cats(case when (type=2) then '$' else ' ' end,length)) into :varlist separated by ' ' from b ; quit; data addi; length &varlist ; .... code to populate variables .... ; run; It would be better to include VARNUM in the metadata so that you could create the variables in the proper order. (Note generating macro variable DUMMY to suppress SQL message when order variable not included in the SELECT list.) proc sql noprint ; select catx(' ',name,cats(case when (type=2) then '$' else ' ' end,length)) , varnum into :varlist separated by ' ' , dummy from b order by varnum ; quit;
... View more