data test;
infile cards truncover;
input temp $100.;
cards;
John
Sex=M
Age=31
Country=US
Allergy=False
Mark
Sex=M
Age=32
Country=US
Allergy=True
Allergy1
Allergy2
Allergy3
Chase
Sex=F
Age=34
Country=UK
Allergy=False
;
data temp;
merge test test(firstobs=2 rename=(temp=_temp));
if _temp =: 'Sex=' then group+1;
run;
data temp;
set temp;
by group;
length name $ 40;
if first.group then do;n=0;name='Name';value=temp;end;
else if findc(temp,'=') then do;name=scan(temp,1,'=');value=scan(temp,-1,'=');end;
else do;n+1;name=cats('Allergy',n);value=temp;end;
keep name value group;
run;
proc transpose data=temp out=want(drop=_name_);
by group;
id name;
var value;
run;
... View more