Hi
Any ideas why I might be getting the 'in range not allowed' error when I use the realcomImpute command to export data from Stata to Realcom?
. realcomImpute deltabmi o.nq4sessions m.ethnic m.tenure m.singlepar m.empstat bmi1c idaci07 age1 sex nprogperpm nperprog towns villages built nq4sessions htroundbin wtroundbin using "Analysis\Change in BMI\dbmirealcom7.dat" ,numresponses(6) cons(cons) level2id(numprogid) replace
6 responses: deltabmi o.nq4sessions m.ethnic m.tenure m.singlepar m.empstat
12 auxiliary variables: bmi1c idaci07 age1 sex nprogperpm nperprog towns villages built nq4sessions htroundbin wtroundbin
in range not allowed
realcomImpute error
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: realcomImpute error
From the output that you have provided it looks like it's having a problem in the following section of code:
As these lines mostly appear to be related to writing to a file I would imagine that the most likely line to be the cause would be
You can confirm this by running the command prior to running the realcomImpute command. If this line is where the problem is occuring then there is probably a problem with the file name that you are specifying for saving the data. The first things I would try would be to specify either the full path, or with no path to see whether you still get the error.
Code: Select all
*save file ready for REALCOM to load
local stoppos = strpos("`using'",".")
if `stoppos'==0 {
local savename `using'.txt
}
else {
local savename `using'
}
file open myFile using `savename', write `replace'
file write myFile "`numresponses'" _n
local numauxvarstotal = `numauxvars'+2
file write myFile "`numauxvarstotal'" _n
file write myFile "`type1'"
forvalues i=2(1)`numresponses' {
file write myFile _tab
file write myFile "`type`i''"
}
file write myFile _n
*write variable names
local myvarlist `respvars_withoutprefix' `level2id' `cons' `auxvars'
tokenize `myvarlist'
local myvarlistlength = `numresponses' + 2 + `numauxvars'
file write myFile "`1'"
forvalues i=2(1)`myvarlistlength' {
file write myFile _tab
file write myFile "``i''"
}
file write myFile _n
*now write data
forvalues i=1(1)`numobs' {
if `1'[`i']==. {
file write myFile (-9.999e+029)
}
else {
file write myFile (`1'[`i'])
}
forvalues j=2(1)`myvarlistlength' {
if ``j''[`i']==. {
file write myFile _tab (-9.999e+029)
}
else {
file write myFile _tab (``j''[`i'])
}
}
file write myFile _n
}
file close myFile
Code: Select all
file open myFile using `savename', write `replace'
Code: Select all
set trace on
Re: realcomImpute error
Dear Chris,
Thanks for the advice. I removed part of the file path and it worked - it was a very slight typo which I hadn't picked up by eyeballing the file path originally.
Good idea on the 'set trace on'. That might be a useful general note for people sending in error messages from Stata for the runmlwin forum too.
Best wishes
Jamie
Thanks for the advice. I removed part of the file path and it worked - it was a very slight typo which I hadn't picked up by eyeballing the file path originally.
Good idea on the 'set trace on'. That might be a useful general note for people sending in error messages from Stata for the runmlwin forum too.
Best wishes
Jamie