hi ... use Linlin's data and Tom's data step, insert PROC SQL in between to find the maximum length of the combined data across the IDs data have; input id line $50.; cards; 100 abcdefghijkollldsdksjd 100 djsjdklsjdksdlsldklskdsld 100 djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoe 100 jksldksldklsldklsdksldksldklskdls 100 djsldksldksldklsdkdadskldkasldklsdksdklskdsk 200 djksldklskdlskdls 200 uuuuuuuuuuuuuuuuuu ; proc sql noprint; select max(lng) into :maxlng separated by ' ' from (select sum(length(line)) as lng from have group by id) ; quit; data want ; length newvar $&maxlng; do until (last.id); set have; by id; newvar=cats(newvar,line); end; drop line; run; ps the "separated by" removes any blanks from around the value of the macro variable ... http://www.sascommunity.org/wiki/Tips:Strip_Blanks_from_PROC_SQL-Created_Macro_Variable_Values
... View more