Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Newbie question on creating variable


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: Newbie question on creating variable
Date   Mon, 1 Mar 2004 19:27:41 -0600

As a variation of Eliot Mason's reply, Stata has several time series operators
explained in the Users Guide at [U] 14.4.3.

One could do the following:

* Assuming that countrycode is a string

. encode country, gen(id)

. tsset id year
       panel variable:  id, 1 to 2
        time variable:  year, 1960 to 1970, but with gaps

. gen diffgdp = s5.gdp
(2 missing values generated)

. l , abbr(16)

     +------------------------------------------+
     | countrycode   year   gdp    id   diffgdp |
     |------------------------------------------|
  1. |         BAN   1960    65   BAN         . |
  2. |         BAN   1965    75   BAN        10 |
  3. |         BAN   1970    85   BAN        10 |
  4. |         CAN   1960    25   CAN         . |
  5. |         CAN   1965    35   CAN        10 |
     |------------------------------------------|
  6. |         CAN   1970    45   CAN        10 |
     +------------------------------------------+


Hope this helps,
Scott


----- Original Message ----- 
From: "Kakatua Kutta" <[email protected]>
To: <[email protected]>
Sent: Monday, March 01, 2004 1:14 PM
Subject: st: Newbie question on creating variable


> countrycode year gdp
> BAN                   1960             65
> BAN                   1965             75
> BAN                   1970             85
> CAN                   1960             25
> CAN                   1965             35
> CAN                   1970             45
>
> Dear Stata users,
> Lets say I have the above data set. I want to create a variable which measures
the difference between the gdp in year 1970 and gdp in 1965 for each country.
That is if "diff" is the new variable it would be diff = gdp(1970)-gdp (1965)
for each country.
> I am a new user and already spent hours on this. I would much appreciate your
help.
> Thanks in advance
> AmBush
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm
>
> *
> *   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/



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