0
votes

I have a database with disease condition per person. Each ID represents a person. I made 1= have disease 0= don't have the disease.

I want to merge each data entry horizontally into a single summary cell for each data entry. So, I am able to get a string of unique 0 and 1.

image : https://docs.google.com/document/d/1ijMlhjrKqlL3uYDaeloL3JrImkC3BjbOUy8oBOn7ThM/edit?usp=sharing

Thanks!

I tried sql and || to merge but it didn't work.

proc sql;
create table want as 
select id, copd, mi,stroke,cancer, summary as copd||mi
from webwork.import
group by id;
quit;

proc print data=webwork.import;
a={copd mi};
b={stroke};
c=a||b;
print c;
1

1 Answers

0
votes

Concatentate the desired columns using the "cat" function.

data have;
input ID copd mi stroke cancer;
datalines;
1 1 0 0 0 
2 0 1 0 0
3 0 1 1 1
4 0 0 0 0
5 1 0 0 1
;
run;

data want;
set have;
Summary=cat(copd,mi,stroke,cancer);
run;