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]
st: Creating particular dummy variables
From
emanuele mazzini <[email protected]>
To
[email protected]
Subject
st: Creating particular dummy variables
Date
Thu, 22 Nov 2012 13:21:55 +0100
Dear all,
I just encountered a (relatively) difficult problem with respect to
the generation of particular dummies. In particular, I have a
structure like the following:
year team_A team_B FT_A FT_B winner dumwin1 dumwin2 dumwin3 dumwin4 dumwin5 dumwin6 dumwin7 dumwin8 dumwin9
1954 Italy Argentina 2 0 1 1 0 0
0 0 0 0 0
0 0
1955 1 1 0 0
0 0 0 0 0
0 0
1956 1 1 0 0
0 0 0 0 0
0 0
1957 1 1 0 0
0 0 0 0 0
0 0
1958 1 1 0 0
0 0 0 0 0
0 0
1959 1 1 0 0
0 0 0 0 0
0 0
1960 1 1 0 0
0 0 0 0 0
0 0
1961 Italy Argentina 4 1 1 1 0 0
0 0 0 0 0
0 0
1962 1 1 0 0
0 0 0 0 0
0 0
1963 1 1 0 0
0 0 0 0 0
0 0
and I would like for the dummies the following structure:
dumwin1=1 in 1954 and 0 otherwise
dumwin2=1 in 1955 and 0 otherwise
and so on until 1961, where the I would like the dummies structure to
be modified as follows:
- on one hand, the dummies should continue to have the same structure
(so in this case only dumwin8 must be =1, while all the others must be
=0)
- on the other had, since a new event occurs, I would like that
dumwin1 is also =1, so as the effects of the 2 events can sum up.
Anyone has a suggestion in order to do that? I guess it is not that
easy, but any suggestion would be appreciated.
I tried with the following loop (after having generated the dumwin1):
forvalues x = 2(1)58 {
gen dumwin`x' = 0
replace dumwin`x' = L.dumwin* if dumwin==`x'
}
but it is not working due to the "ambiguous abbreviation" error wrt
the variable dumwin.
Does anyone of you can tell me if this is the good way to proceed and
how to fix the command, or either if there's another way to make what
I want?
Thank you all in advance,
Regards,
E.M.
*
* 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/