Quantcast
Channel: The Stata Blog - Latest Comments
Viewing all articles
Browse latest Browse all 1129

Re: How to successfully ask a question on Statalist

$
0
0

Hello! I urgently need your help pleeeeaseeee...i am trying to make a ttest of 2 variables and have coded it like this:
--------------------------------
use "I_final.dta"

append using "JP_final.dta"

drop if year!= 2004 & year!=2005

gen Group = (nation == "ITALY")
tabulate Group, gen(g)

gen Time = (year == 2005)
tabulate Time, gen(t)

////////////////////////ttest Difference1/////////////////////////////////
gen Variable1=.
replace Variable1=ZERORET[_n] if Group==1 & Time == 1
replace Variable1=0 if Variable1==.

mvdecode Variable1, mv(0=.a)

gen Variable2=.
replace Variable2=ZERORET[_n] if Group==1 & Time == 0
replace Variable2=0 if Variable2==.

mvdecode Variable2, mv(0=.b)

ttest Variable1=Variable2

--------------------------------
Variable1 just contains the values of ZERORET in the case of group=1 and time=1. Variable2 just contains the values of ZERORET in the case of group=1 and time=0. The other values are going to be zero. For this reason, i have decoded the numeric "zero" in a missing value ".a" and ".b"
the problem appears in the last code: it is appearing "no observations"....although Variable 1 and Variable 2 have numeric values (and missing values, which i have coded as a missing value)

i am not getting the problem.

pleas i need your help.

Thank you very much for now!

Andrea


Viewing all articles
Browse latest Browse all 1129

Trending Articles