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

Re: st: Re: Categorical variable


From   Katarina Sikavica <[email protected]>
To   [email protected]
Subject   Re: st: Re: Categorical variable
Date   Fri, 22 Jul 2005 16:57:07 +0200

austin:
as a beginner I don't know whether it is common to send thank-you-mails.
anyway: many thanks for your help!
best,
katy

Inactive hide details for austin nichols <austinnichols@gmail.com>austin nichols <[email protected]>



An

[email protected]

Kopie


Thema

st: Re: Categorical variable

I sincerely doubt your variable names have spaces in them, so I will
assume they are named v1, v2, etc. up to v99 and have labels "poor
performance", "retirement", etc. assigned via the -label var v1 "poor
performance" command.

Then you can

gen byte onevar=.
forval i=1/99 {
local l: var la v`i'
la def onevar `i' "`l'", modify
replace onevar=`i' if v`i'==1
}
la val onevar onevar
tab onevar

and if you really need a string variable, you can

decode onevar, gen(onestrvar)

-----Original Message-----
From: Katarina Sikavica [mailto:[email protected]]
Sent: Friday, July 22, 2005 9:19 AM
Subject: Re: st: Categorical variable

actually: I've collected data on reported reasons for CEO turnover (as
stated in newspaper articles); my dummy variables look like this:

- poor performance (1/0)
- retirement (1/0)
- policy differences (1/0)
- ....

Now I would like to create a single new variable called "reason" that
looks like this:
one and only variable "reason" coded as follows:

1 poor performance
2 retirement
3 policy differences
4 ....

best,
Katy

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

GIF image




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