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

st: Urgent: Saving Coefficient

From   "Kakatua Kutta" <>
Subject   st: Urgent: Saving Coefficient
Date   Wed, 24 Mar 2004 18:27:55 -0500

Country Code	Year	GDP
BAN	        1960	65
BAN	        1965	75
BAN	        1970	85		
CAN	        1960	25
CAN	        1965	35
CAN	        1970	45

Dear Stata Users,

Suppose I have the above data set. 
1.I want to regress GDP on year (reg GDP Year) for each country
2.Then I want to create a variable named "coeff" which saves the coefficent of Year variable from the each country regression above. 
gen coeff=_b[year]

I have used the following method:
use data
sort countrycode year
encode countrycode,gen(id)
tsset id year
forv id=1/2 {
reg gdp year 
gen coeff=_b[year]

It is not working. Is there any way to make it work or you guys have better solution?
I would highly appreciate any help.



Sign-up for Ads Free at

*   For searches and help try:

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