Bookmark and Share

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]

Re: st: Binary variable (create a flag) in STATA and deleting variables


From   Alfonso Sánchez-Peñalver <[email protected]>
To   Stata List <[email protected]>
Subject   Re: st: Binary variable (create a flag) in STATA and deleting variables
Date   Sun, 12 Jan 2014 17:36:53 -0500

Hi,

to generate the binary variable you just need to write one command, but it will have to have all codes. Thus

gen cancer = (medicalcode == "88zuu00" | medicalcode == "25C5.00" | etc.)

where etc will be a series of medicalcode == to the different codes that reflect cancer. I am not sure I understand the second question you ask.

Best,

Alfonso Sanchez-Penalver

On Jan 12, 2014, at 5:30 PM, [email protected] wrote:

> 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/


*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index