Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Categorical variable


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: Categorical variable
Date   Fri, 22 Jul 2005 08:07:23 -0500

At 02:43 PM 7/22/2005 +0200, Katarina Sikavica wrote:

Hi Alice,
hi all,

I have the same problem.... in addition to the below question I would like to know whether and how I can generate a string variable out of say 3 or more dummy variables.

cheers,
Katy
Katy, could you be more specific as to what you have in mind? Anyway, one way might be

gen x = 100 * dummy_1 + 10 * dummy_2 + dummy_3
tostring x, gen(xstring)

I suspect that isn't what you have in mind though, e.g. maybe you want a string variable with values like "high" "medium" "low" ? Perhaps something like

. gen y = "high" if dummy_1 == 1
. replace y = "medium" if dummy_2 == 1
. replace y = "low" if dummy_3 == 1


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index