generating a categorical variable but some entries overlap

generating a categorical variable but some entries overlap

by Rima Arnaout -
Number of replies: 3

Hi, 

I am looking at a bunch of dichotomous variables. Several are types of MI [0 vs 1]. I tried to recode into a categorical variable of 'mitypes.' But the problem is that some patients have more than one type of MI coded, so that I lose total numbers of each type: for example, the MI type I set as "1," some get overturned when I set the next MI type "2" and some of the first type overlap with the second type.

I could recode all overlaps as missing, but I don't think that's consistent with the data.

I could keep each MI type as separate dichotomous variables, but I'm afraid when you look at my log file it will look like I didn't try to do anything even halfway sophisticated to generate my table values. 

I'm going to try to see if there's one special order I could give to generating the different MI types that would eliminate the 'overturn' problem. But if that doesn't work, will I get dinged for assembling my table data from a bunch of separate commands for dichotomous variables?

Thanks

Rima

In reply to Rima Arnaout

Re: generating a categorical variable but some entries overlap

by Wayne Enanoria -

If the MI groups are mutually exclusive, you should not have a problem with coding them. Can you send me enough of your code where I can take a look and see how you are coding the new variable? Can you post a snippet of your code?

To answer your questions, I do not believe you will be "dinged" for assembling your table from a group of dichotomous variables. 

In reply to Wayne Enanoria

Re: generating a categorical variable but some entries overlap

by Rima Arnaout -

Thanks, 

The problem is, there are 16 instances where they are not coded as mutually exclusive.

 

This is what I first tried:

// generate a categorical variable that can describe mi types
generate mitypes = 0
replace mitypes = 1 if mi_spasm_da == 1 
replace mitypes = 2 if mi_cas_da == 1
replace mitypes = 3 if mi_takosubo_da == 1
replace mitypes = 4 if mi_hypercoag_da == 1
replace mitypes = 5 if mi_caa_da == 1
tab mitypes

 

But using tab, it is clear that there are 16 overlaps, as summarized here:

  spasm dissection takotsubo hypercoag anomaly
spasm   2 3 3 0
dissection     0 0 6
takotsubo       0 2
hypercoag         0
anomaly          

 

So when I code the next 'mitype =  2,' it 'overturns' two of the mitypes coded as 1. And etc.

I don't think this is an error per se, but that it is possible for a patient to have had both spasm and dissection, for example.

I was able to get the table by running each dichotomous variable. But I still want to figure out a more elegant way. I am trying to see if 'recode' will fix this, but it doesn't look like it... Is there a way to code each mitype without 'overturning' the ones that overlap?

 

Thanks

 

 

 

In reply to Rima Arnaout

Re: generating a categorical variable but some entries overlap

by Wayne Enanoria -

If the data has overlap in the group levels then it is not a coding issue but rather it is inherent in the data itself. You could add additional conditions as in:

replace mitypes = 2 if (mi_cas_da == 1 & somevar==somevalue)

so that both conditions must be TRUE in order to be assigned to level 2. But I understand that the data may have overlap in the groups (from reading your post). Is there a way to be more specific with the criteria that define the various levels of your variable?