Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: how do you re-categorize a string variable?


From   Gwinyai Masukume <parturitions@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: how do you re-categorize a string variable?
Date   Wed, 24 Apr 2013 06:56:42 +0200

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index