Generating a dichotomous variable

Generating a dichotomous variable

by Archna Eniasivam -
Number of replies: 1

I'm in the process of cleaning up my data set and am hitting a road block in trying to create a dichotomous variable from a continuous. I generated a new variable looking at days until readmission. Within that I want to have days < 7 = 0 and days >7 = 1. Does having blanks for those patients who never got readmitted matter? I've tried both a replace command and recode command:

i.e. recode days_until_readmission min/7=0 8/max=1 ; then I get the following error: recode only allows numerical variables.

 

Any thoughts? Thanks.

In reply to Archna Eniasivam

Re: Generating a dichotomous variable

by Dominika Seidman -

The way that I would approach this problem is first creating a variable of whether a patient got readmitted or not. STATA can't interpret "blanks" - they need to be coded as something ("." will suffice, although you won't be able to tell the difference between missing data and those subjects who weren't readmitted. that's why an additional variable of readmitted or not is helpful). Then, I'd look at only patients who were readmitted, and create a new variable of whether they were readmitted in less then 7 days or not. Then, if you still get that error code, you likely have string variables in your output somewhere which need to be "destrung" before recoding. I hope this answers your question.