Statalist


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

Re: st: generate


From   "Scott Merryman" <[email protected]>
To   [email protected]
Subject   Re: st: generate
Date   Sat, 28 Jul 2007 15:23:16 -0500

Another way:


drop _all
input str9 company_name year    var1    var2    var3
firm_A                  1990    3       2       5
firm_A                  1991    4       2.4     4.8
firm_B                  1990    2       1.5     4
firm_B                  1991    2       1.6     4.1
all_firms               1990    30      50      56
all_firms               1991    32      61      87
end

sort com year
gen foo=.
forv i = 1/2 {
replace foo = var1/var1[`i'] if year ==`=1989 + `i''
}

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