Hello,
I have GDP per capita data for the USA and USSR, along with the year, country codes and a dummy variable that I generated. I have a variable, rgdpnapc, GDP per capita, that I want to divide for each year between the two countries. For example, 1917 Soviet GDP per Capita/1917 US GDP per Capita. I am trying to do it with loops, but am stuck If I could get some help, that would be great. I have attached the data set and the code
**Load, Rename and Describe Historical GDP Data**
clear
import excel "C\filepath.xlsx", sheet("Full data") firstrow
label var cgdppc "Real GDP per Capita - 2011 Income Comp"
label var rgdpnapc "Real GDP per Capita - 2011 Growth Comp"
gen popmil = pop/1000
label var popmil "Population - Millions"
keep countrycode country year cgdppc rgdpnapc popmil
list countrycode year cgdppc if countrycode == "USA" | countrycode == "SUN"
**Compare the USA and USSR**
keep if countrycode == "USA" | countrycode == "SUN"
keep if year >= 1917 & year <= 1991
gen GDPCompDummy = 0 if countrycode == "USA"
replace GDPCompDummy = 1 if countrycode == "SUN"
gen SOVGDP = rgdpnapc if GDPCompDummy == 1
gen USAGDP = rgdpnapc if GDPCompDummy == 0
foreach x of SOVGDP USAGDP {
gen percGDP = `SOVGDP'/`USAGDP'
}
Related Posts with Question about How to Divide Observations within a Single Variable using Loops
Customization of graph combine with three graphsHi Statalisters I am working on a visualization where I am interested in the following graph combin…
Logit FE regression in cross-sectional data.Dear Statalist, I have read about this topic in various discussions but I could not take a clear re…
Errors while testing for serial correlation and generating a new variableDear everyone, I am new to this page. I want to ask two questions, please I want to apologize if …
After having run a robust regression, do I still need to test for heteroskedasticity?"regress indep dep control control vce(robust)" After the regression, Stata doesn't allow me to use …
Sample size calculation using Cohen's d / Hedges's gHi everyone, Can anyone please advise me on how to perform a sample size calculation using Cohen's …
Subscribe to:
Post Comments (Atom)
0 Response to Question about How to Divide Observations within a Single Variable using Loops
Post a Comment