I’ve been trying to run the runtest command on a measured variable (which I call mv) which is split by site. I’ve been trying to run it on groups of observations within each site. The whole lot are numbered 1 to 5894, but not all numbers are used, and I used 1100 just as an example.
I couldn’t get the by option to work with the command, while trying preserve and restore thus:
sort site id
forvalues i = 1/1100{
preserve
keep if site==`i'
display "site", "`i'"
runtest mv
restore
}
gave me an error message:
. forvalues i = 1/1100{
2. preserve
3. keep if site==`i'
4. display "site", "`i'"
5. runtest mv
6. restore
7. }
(5,691 observations deleted)
site 1
N(mv <= 2.25) = 25
N(mv > 2.25) = 25
obs = 50
N(runs) = 29
z = .86
Prob>|z| = .39
(5,741 observations deleted)
site 2
no observations
r(2000);
I’m wondering why the restore command seems not to work.
Any ideas?
I couldn’t get the by option to work with the command, while trying preserve and restore thus:
sort site id
forvalues i = 1/1100{
preserve
keep if site==`i'
display "site", "`i'"
runtest mv
restore
}
gave me an error message:
. forvalues i = 1/1100{
2. preserve
3. keep if site==`i'
4. display "site", "`i'"
5. runtest mv
6. restore
7. }
(5,691 observations deleted)
site 1
N(mv <= 2.25) = 25
N(mv > 2.25) = 25
obs = 50
N(runs) = 29
z = .86
Prob>|z| = .39
(5,741 observations deleted)
site 2
no observations
r(2000);
I’m wondering why the restore command seems not to work.
Any ideas?
Comment