[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Robin Luo <rluosf@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How to transfer a variable's value into a macro (in a panel dataset) |

Date |
Sat, 26 Feb 2005 11:24:59 -0800 |

Thanks a lot for all your inputs - they are really really helpful! Have a nice weekend! Robin On Sat, 26 Feb 2005 06:03:29 -0800 (PST), Gregory Branch <greg_branch@gfbonline.org> wrote: > I haven't spent a lot of time thinking about this, but > it might be more efficient to take a slightly > different tack on this. Something like the following > might work: > > 1) Make a second copy of your data set. > 2) Generate a column of "1"s > 3) reshape wide, i = year, j = firm, xij = whatever > you called the column of ones. > 4) merge back onto the original dataset by year. > > Best of luck > > Greg Branch > Research Scientist, > UT Dallas/Texas Schools Project > > > --- Robin Luo <rluosf@gmail.com> wrote: > > > Sorry for the confusion. Let me explain the > > situation in more details: > > > > I have a variable called "firmid" and I generate a > > set of dummy > > variables from it. Now I need to use the value of > > the varialbe > > "firmid" to locate the dummy variables and do some > > calculations but > > the location part confuses me. Basically, my data > > has the following > > structure: > > > > firmid year firm_100 firm_101 firm_102 > > firm_103 firm_104 ...... > > 100 1980 > > 101 1980 > > 105 1980 > > 121 1980 > > 124 1980 > > 101 1981 > > 103 1981 > > 196 1981 > > > > The data has been sorted by year and my goal is to > > check in each year > > which firms co-exist with a certain firm - for those > > coexisting, their > > respective dummy variables will be changed to 1 > > accordingly. For > > example, firm 100, 101, 105, 121, 124 coexist in > > 1980. Therefore, for > > the record where firmid=100 and year=1980, variables > > firm_101, > > firm_105 and likewise will be changed to 1. My plan > > is that for each > > year group check the values of "firmid" and then > > output these values > > to a local macro, which can be used to locate the > > corresponding firm > > dummy variables. But, as stated in my firm mail, I > > was stuck in how to > > do this macro set-up in a groupwise environment. > > > > Many thanks! > > > > Robin Luo > > > > On Sat, 26 Feb 2005 00:44:34 +0000, Ada Ma > > <pec187@abdn.ac.uk> wrote: > > > you can't use -by- for setting locals because you > > can only have one value for > > > each local value. i can only equals to one thing, > > it's not like a variable in > > > the dataset which can carry multiple values. > > > > > > what are you trying to do anyway? if you tell us > > what you're actually trying to > > > do then may be someone can work out the solution > > for you. > > > > > > > > > Robin Luo wrote: > > > > > > > I know that a command like: > > > > > > > > local i = var[`n'] > > > > > > > > can obtain the nth observation's value into > > macro i. But my data is a > > > > panel data and I want the nth observation within > > a certain group into > > > > the macro i, instead of that of the nth > > observation in general. > > > > Obviously, "local" cannot be used with "by" and > > I could not figure out > > > > a way to do this. If any one has any idea on > > this, I would really > > > > appreciate. > > > > > > > > Thanks! > > > > > > > > Robin Luo > > > > > > * > > > * 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/ > > > > > * > > * 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/ > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - Helps protect you from nasty viruses. > http://promotions.yahoo.com/new_mail > * > * 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/ > * * 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/

**References**:**Re: st: How to transfer a variable's value into a macro (in a panel dataset)***From:*Robin Luo <rluosf@gmail.com>

**Re: st: How to transfer a variable's value into a macro (in a panel dataset)***From:*Gregory Branch <greg_branch@gfbonline.org>

- Prev by Date:
**Re: Fwd: st: tsset error in panel estimation** - Next by Date:
**st: RE: Disappearing Review Window** - Previous by thread:
**Re: st: How to transfer a variable's value into a macro (in a panel dataset)** - Next by thread:
**RE: st: How to transfer a variable's value into a macro (in a panel dataset)** - Index(es):

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