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: how do you re-categorize a string variable?


From   Gwinyai Masukume <[email protected]>
To   [email protected]
Subject   Re: st: how do you re-categorize a string variable?
Date   Wed, 24 Apr 2013 07:17:16 +0200

Hi Darren,

changed to:
replace hypertension_status = "hypertensive" if hypertension == "mild"|
hypertension == “moderate” | hypertension == “severe”

works nicely - thanks
had forgotten that in Stata, equals --> ==

thanks again,
gwinyai

On 4/24/13, Darren White <[email protected]> wrote:
> Hi Gwinyai
>
> You may need a == in your if statement
>
> eg: replace hypertension_status = "hypertensive" if hypertension ==
> "mild"  etc etc
>
> or maybe you have a numeric variable with text labels if so
>
> use command:
> tab hypertension, nolabel
>
> to view the numeric codes
>
> cheers
>
> Darren
>
>
>>>> Gwinyai Masukume <[email protected]> 4/24/2013 2:56 pm >>>
> Dear Stata listers,
>
> I have a dataset with the string variable hypertension. Observations
> of the variable hypertension can be mild, moderate, and severe or no
> hypt (no hypertension):
>
> hypertension
> .
> mild
> .
> .
> moderate
> .
> severe
> no hypt
> severe
> .
> .
> mild
> mild
> .
> no hypt
> .
>
> I would like to create a new variable, hypertension_status, which
> ‘distingushes’ if an individual is hypertensive or not.
>
> generate hypertension_status = hypertension
> replace hypertension_status = "hypertensive" if hypertension = "mild"|
> hypertension = “moderate” | hypertension = “severe”
>
> I am getting:
> type mismatch
> r(109);
>
> How can I formulate the command?
>
> Kind regards,
> Gwinyai
>
> *
> *   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/
>
> ********************************************************************************
> This email, including any attachments sent with it, is confidential and for
> the sole use of the intended recipient(s). This confidentiality is not
> waived or lost, if you receive it and you are not the intended recipient(s),
> or if it is transmitted/received in error.
> Any unauthorised use, alteration, disclosure, distribution or review of this
> email is strictly prohibited.  The information contained in this email,
> including any attachment sent with it, may be subject to a statutory duty of
> confidentiality if it relates to health service matters.
> If you are not the intended recipient(s), or if you have received this email
> in error, you are asked to immediately notify the sender by telephone
> collect on Australia +61 1800 198 175 or by return email.  You should also
> delete this email, and any copies, from your computer system network and
> destroy any hard copies produced.
> If not an intended recipient of this email, you must not copy, distribute or
> take any action(s) that relies on it; any form of disclosure, modification,
> distribution and/or publication of this email is also prohibited.
> Although Queensland Health takes all reasonable steps to ensure this email
> does not contain malicious software, Queensland Health does not accept
> responsibility for the consequences if any person's computer inadvertently
> suffers any disruption to services, loss of information, harm or is infected
> with a virus, other malicious computer programme or code that may occur as a
> consequence of receiving this email.
> Unless stated otherwise, this email represents only the views of the sender
> and not the views of the Queensland Government.
> **********************************************************************************
>
> *
> *   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