Page 1 of 1

Variable not allowed

Posted: Fri Nov 02, 2012 10:22 am
by Jamoo
Hi there,

Using realcomimputeLoad, I get the following error (see snippet from the command after set trace was set to on). Specifically, the second variable preemo listed in the impvals file (file copied in below the error as couldn't attach it) was not allowed.

Has anyone seen this before?

Thanks

Jamie

***************error snippet begins*********
------------------------------------------------ end reshape.Macdrop ---
- exit _rc
---------------------------------------------------- end reshape.DoNew ---
- exit
------------------------------------------------------------ end reshape ---
- quietly forvalues i=1(1)`numimputations' {
= quietly forvalues i=1(1)4 {
- local filename`i' = v in `i'
= local filename1 = v in 1
- }
- local filename`i' = v in `i'
= local filename2 = v in 2
- }
- local filename`i' = v in `i'
= local filename3 = v in 3
- }
- local filename`i' = v in `i'
= local filename4 = v in 4
- }
- quietly forvalues i=1(1)`numimputations' {
= quietly forvalues i=1(1)4 {
- insheet using "`filename`i''.", tab clear nonames
= insheet using "imputeiter250.", tab clear nonames
- forvalues j=1(1)`numimputedvars' {
= forvalues j=1(1)1 {
- rename v`j' `varname`j''`i'
= rename v1 bmi2c preemo postemo prehyper posthyper prepeer postpeer prepro po
> stpro preser postser prediet postdiet prepa postpa pcsessions ethnic tenure s
> inglepar empstat1
preemo not allowed
}
save imp`i', replace
}
---------------------------------------------------- end realcomImputeLoad ---
r(101);

end of do-file

r(101);

********error snippet ends*********

**********impvals was as follows**********************

bmi2c preemo postemo prehyper posthyper prepeer postpeer prepro postpro preser postser prediet postdiet prepa postpa pcsessions ethnic tenure singlepar empstat
13350
4
imputeiter250 imputeiter500 imputeiter750 imputeiter1000

Re: Variable not allowed

Posted: Fri Nov 02, 2012 10:47 am
by ChrisCharlton
It looks as if insheet is reading all the variable names into one variable instead of creating one for each. This means that rename is attempting to rename the variable v1 to the whole list of names in your data. You should be able to confirm this with the command:

Code: Select all

insheet using impvals.txt, clear nonames
and then browsing the loaded data.

If this is the case you will need to either modify impvals.txt so that insheet understands it or change the insheet command at the beginning of realcomImputeLoad so that it is able to correctly interpret the file.

Re: Variable not allowed

Posted: Fri Nov 02, 2012 11:18 am
by Jamoo
Hi Chris,

Many thanks. It was the impvals file not being tab delimited.

Best wishes

Jamie