proc sort data=test;
by id;
run;
data test1;
set test;
by id;
if first.id then order=0;
order+1;
run;
proc sort data=test1;
by order id;
run;
data test2;
set test1 end=last;
by order;
if first.order then num=0;
num+1;
if _n_=1 then call execute('data wanted;');
call execute('id'||cats(num)||'='||quote(strip(id))||';content'||cats(num)||'='||quote(strip(content))||';');
if last.order then call execute('output;');
if last then call execute('run;');
run;