Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Aggregate and Microdata


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Aggregate and Microdata
Date   Mon, 18 May 2009 22:41:38 +0200

<> 

Look at -h tsvarlist- and use the lag operator "L." there. Although your
approach should work in priciple...


*************
clear*
set obs 100

//unbalanced!
gen x=  cond(runiform()<0.1,.,rnormal())

//for by
gen dummy=_n>_N/2

bys dum: gen y=x[_n-1]

l, noo sepby(dum)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Luis Bernardo
Torres Ruiz
Gesendet: Montag, 18. Mai 2009 22:30
An: statalist@hsphsun2.harvard.edu
Betreff: st: Aggregate and Microdata

Dear Stata Users,

Im using a microdata set. Im estimating aggregates with the data set. The
data set is unbalanced. A situation arises when I lag the variables by

sort  PLANT YEAR STATE COUNTY ECOGROUP FIRM
quietly by PLANT:  gen Ait1= aggregateprod[_n-1]

It generates missing values for the lag variable of the aggregate, but there
should a value(with the exception of the first year), since Ait is the
aggregate value by year. How can I change the missing values to the actual
values without doing a replace for each year. I thank you in advance for all
your help.

Sincerely,

Luis
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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