10 symptiom variables -Combination and permutation of all symptoms

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

10 symptiom variables -Combination and permutation of all symptoms

Hi

 

I have a databse of 1000 or so observations of patients. Each patient can have 10 symptoms which is in numerica varavble (yes or no or not answered)

 

I want to create an out put tables  of 2 symptoms (for eg fever and headache or headache and vomiting), 3 symptoms, 4 symptoms etc.

 

I can do a lengthny sas program with lots of and and or statments but wanted to knwo if a shortcut program exists. I saw teh Proc PLAN but could nto understand and i think many people use it for randomization.

 

Any help will be highlyappreciated.

 

Thanks

Manjunath


Accepted Solutions
Solution
‎08-04-2016 04:31 PM
Respected Advisor
Posts: 4,606

Re: 10 symptiom variables -Combination and permutation of all symptoms

I suggest not to generate all possible combinations, only combinations with at least one patient :

 

data have;
input PatId	Fever	Headache	Vomiting;
datalines;
1	1	.	1
2	1	1	1
3	1	0	1
4	1	1	0
5	0	0	1
;

data sList;
length sList $200;
set have;
array _s Fever -- Vomiting;
do i = 1 to dim(_s);
    if _s{i} > 0 then sList = catx(" and ", sList, vname(_s{i}));
    end;
keep patId sList;
run;

proc sql;
create table sCounts as
select sList, count(*) as nbPat
from sList
group by sList;
quit;

PG

View solution in original post


All Replies
Grand Advisor
Posts: 10,210

Re: 10 symptiom variables -Combination and permutation of all symptoms

It would help if you could provide an small example of some input, though it need not have all 10 variables, 3 should. Then an example of what the output should look like given that input.

 

 

Occasional Contributor
Posts: 5

Re: 10 symptiom variables -Combination and permutation of all symptoms

[ Edited ]

Hi Ballardw

 

Thanks for the response. Sorry for not explaining more. Here is an example of what I want

 

Input database

 

Patient id

Fever

Headache

Vomiting

1

1

.

1

2

1

1

1

3

1

0

1

4

1

1

0

5

0

0

1

 

Output Desired:

Symptom Combination

Number of patients

Fever only

0

Headache only

0

Vomiting Only

1

Fever and Headache

1

Fever and Vomiting

2

Vomiting and headache

0

All three (fever ,headache and vomiting)

1

 

Hope this clarifies the problem.

 

Thanks in advance

with regards

Manjunath

Solution
‎08-04-2016 04:31 PM
Respected Advisor
Posts: 4,606

Re: 10 symptiom variables -Combination and permutation of all symptoms

I suggest not to generate all possible combinations, only combinations with at least one patient :

 

data have;
input PatId	Fever	Headache	Vomiting;
datalines;
1	1	.	1
2	1	1	1
3	1	0	1
4	1	1	0
5	0	0	1
;

data sList;
length sList $200;
set have;
array _s Fever -- Vomiting;
do i = 1 to dim(_s);
    if _s{i} > 0 then sList = catx(" and ", sList, vname(_s{i}));
    end;
keep patId sList;
run;

proc sql;
create table sCounts as
select sList, count(*) as nbPat
from sList
group by sList;
quit;

PG
Occasional Contributor
Posts: 5

Re: 10 symptiom variables -Combination and permutation of all symptoms

Thanks PGstats, this worked liek a charm!!

 

Kind Regards

Manjunath

Respected Advisor
Posts: 3,775

Re: 10 symptiom variables -Combination and permutation of all symptoms

Treat missing same as no (0) and count.

 

data have;
   infile cards expandtabs;
   input PatId	Fever	Headache	Vomiting;
   datalines;
1	1	.	1
2	1	1	1
3	1	0	1
4	1	1	0
5	0	0	1
;;;;
   run;
proc stdize data=have out=have2 missing=0 reponly;
   var Fever--Vomiting;
   run;
proc print;
   run;
proc summary data=have2 nway;
   class Fever--Vomiting;
   output out=counts;
   run;
proc print;
   run;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 331 views
  • 6 likes
  • 4 in conversation