Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiply a fix variables_newvar

    Hi,
    I a newbie in stata. This is an elementary question. I need to create a new variables which is the product of GDP for partner countries.

    I understand that the command is gen (newvar)=X*Y, how ever in my case I need the new variables to be a products of GDP USA * GDP 20 list of countries and its in 10 years observations. I'm using the long format for my panel data format (Meaning the variables are in the same column differ by country)

    how do I do this?
    Thanks in advance

    -Diana-


  • #2
    You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    I don't really understand what you're trying to calculate. Note that gen newvar=x*y works just fine (without the parentheses). So, you want to multiply the GDP of the USA times what? And how exactly does "10 years observation" fit in? This may be the rare case where a wide format would be easier to do your calculations, but I can't be sure.

    If you want to multiple US GDO in year t times the GDP of each other country, you could start by putting the US GDP in each observation (including the non-use observations) you might try:

    bysort year: egen usgdp1=mean(usgdp)

    then you can multiply country gdp by us

    g gdpint=gdp * usgdp1

    Comment

    Working...
    X