Hi guys,
I'm very new with stata so.... please forgive me for some stupid questions...
I need to calculate many scalars. I did it with many and many lines like these
mean Q1 Q2 Q3 P1 P2 E if YEAR == 2005
scalar Q1m05 = _b[Q1]
scalar Q2m05 = _b[Q2]
scalar Q3m05 = _b[Q3]
scalar P1m05 = _b[P1]
scalar P2m05 = _b[P2]
scalar Em05 = _b[E]
mean Q1 Q2 Q3 P1 P2 E if YEAR == 2006
scalar Q1m06 = _b[Q1]
scalar Q2m06 = _b[Q2]
scalar Q3m06 = _b[Q3]
scalar P1m06 = _b[P1]
scalar P2m06 = _b[P2]
scalar Em06 = _b[E]
and so on for each year from 2005 to 2012
I tried tihs solution but it does not work
forvalues x=2005/2012 {
mean Q1 Q2 Q3 P1 P2 E if YEAR == `x'
scalar Q1m`x’ = _b[Q1]
scalar Q2m`x’ = _b[Q2]
scalar Q3m`x’ = _b[Q3]
scalar P1m`x’ = _b[P1]
scalar P2m`x’ = _b[P2]
scalar Em`x’ = _b[E]
}
how can I solve?
many tks
I'm very new with stata so.... please forgive me for some stupid questions...
I need to calculate many scalars. I did it with many and many lines like these
mean Q1 Q2 Q3 P1 P2 E if YEAR == 2005
scalar Q1m05 = _b[Q1]
scalar Q2m05 = _b[Q2]
scalar Q3m05 = _b[Q3]
scalar P1m05 = _b[P1]
scalar P2m05 = _b[P2]
scalar Em05 = _b[E]
mean Q1 Q2 Q3 P1 P2 E if YEAR == 2006
scalar Q1m06 = _b[Q1]
scalar Q2m06 = _b[Q2]
scalar Q3m06 = _b[Q3]
scalar P1m06 = _b[P1]
scalar P2m06 = _b[P2]
scalar Em06 = _b[E]
and so on for each year from 2005 to 2012
I tried tihs solution but it does not work
forvalues x=2005/2012 {
mean Q1 Q2 Q3 P1 P2 E if YEAR == `x'
scalar Q1m`x’ = _b[Q1]
scalar Q2m`x’ = _b[Q2]
scalar Q3m`x’ = _b[Q3]
scalar P1m`x’ = _b[P1]
scalar P2m`x’ = _b[P2]
scalar Em`x’ = _b[E]
}
how can I solve?
many tks
Comment