Bookmark and Share

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]

Re: st: forvalues, panel data


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: forvalues, panel data
Date   Thu, 30 Sep 2010 15:15:25 -0400

See also
ssc d cpigen

On Thu, Sep 30, 2010 at 9:37 AM, David Kantor <[email protected]> wrote:
> Putting aside the -forvalues- issues, which were addressed in another
> response by Nick Cox, you may be interested in my -cpiadj- program for doing
> cpi-adjustments. This covers the U.S. cpi (Consumer Price Index) from 1976
> through 2004, though it could certainly be enhanced to cover the latest
> available years. It does the general all-items, all-US-consumers flavor,
> plus several others (food, shelter, etc.).
> If you are interested, write to me privately. This has not been made public,
> but if there is interest, I would consider publishing it.
> --David
> [email protected]
>
> At 05:58 AM 9/30/2010, Biljana wrote:
>
>> I have panel data (companies, fiscal years) and need to deflate numbers
>> to US$ 1980
>>
>> tsset  gvkey_n  fyear
>>
>> I used forvalues function and did it like this:
>>
>> First I created variable just with dots:
>>
>> gen dI2=.
>>
>> Then simple forvalues loop
>>
>> .forvalues fyear = 1980/1990 {
>> .replace dI2=I2*1 if fyear==1980
>> .replace dI2=I2*0.967059 if fyear==1981
>> .replace dI2=I2*0.421106 if fyear==1982
>> ...
>> .replace dI2=I2*0.307175 if fyear==1990
>> }
>>
>> So that works, but since I have 10 variables (from I1 to I10) that need
>> to be deflated, repeating the whole procedure is time consuming... so I
>> tried by using var i=I1-I10, etc... but always got reply invalid
>> syntax...
>> [...]
>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index