Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Binary variable (create a flag) in STATA and deleting variables
From
"[email protected]" <[email protected]>
To
[email protected]
Subject
st: Binary variable (create a flag) in STATA and deleting variables
Date
Sun, 12 Jan 2014 23:30:21 +0100
Dear all,
I have two questions:
1. I want to create a binary variable (create a flag) in STATA
I’ve got a file cancer.dta
- containing list of medical codes (e.g. 88Zuu00, 25C5.00) that mean a
person has a cancer.
I have also a second file health_record.dta
- with different variables about patient. One of the variables are
medical codes (for cardiovascular disease, diabetes and of course
CANCER).
I want to create a binary variable (flag) that would indicate if a
person has cancer.
So far I did something like this:
gen cancer=.
replace cancer = 1 if medicalcode=="88Zuu00"
replace cancer = 0 if medicalcode !=" 88Zuu00"
replace cancer = 1 if medicalcode =="25C5.00" | medicalcode == "25C5.01" | etc.
But etc. in this case means that I have to reaped the command for over
200 cases. Is there a quicker, more sufficient way?
2. Will deleting a variable that I created just to count other
variables affect their result? Like in Excel when I delete a cell,
then if there was reference to that cell it is all gone. Is Stata the
same in that matter?
I apologize if you so the first question already in another message. I
think that for future reference this problem should be in separate
message.
Kind Regards
John
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/