Hi,
I am importing a dataset from excel but when I am proceeding to add observations by using the command: set obs '=_N+11' I get an error stating observation number out of range. I haven't encountered this error before.
I have set trace on at the start but cannot figure out where the problem is while exporting. The import trace commands appearing are as follows:
- version 12
- scalar ImpExcelCleanUp = -1
- capture noi import_excel `macval(0)'
= capture noi import_excel "F:\Dataset.xls", sheet("Sheet1") firstrow
------------------------------------------------------------------------------------- begin import_excel ---
- version 12
- if ("`c(excelsupport)'" != "1") {
= if ("1" != "1") {
dis as err `"import excel is not supported on this platform."'
exit 198
}
- gettoken filename rest : 0, parse(" ,")
- gettoken comma : rest, parse(" ,")
- if (`"`filename'"' != "" & (trim(`"`comma'"') == "," | trim(`"`comma'"') == "")) {
= if (`"F:\Dataset .xls"' != "" & (trim
> (`","') == "," | trim(`","') == "")) {
- local 0 `"using `macval(0)'"'
= local 0 `"using "F:\Dataset.xls", sh
> eet("Sheet1") firstrow"'
- }
- capture syntax using/, DESCribe
- if _rc {
- capture syntax using/ [, ALLSTRING(string) *]
- local fmtstring `"`allstring'"'
= local fmtstring `""'
- capture syntax using/ [, SHeet(string) CELLRAnge(string) FIRSTrow ALLstring(string) ALLstring case(string)
> locale(string) clear]
- if _rc {
syntax [anything(name=extvarlist id="extvarlist" equalok)] using/ [, ALLSTRING(string) *]
local fmtstring `"`allstring'"'
syntax [anything(name=extvarlist id="extvarlist" equalok)] using/ [, SHeet(string) CELLRAnge(string) FIRST
> row ALLstring(string) ALLstring locale(string) clear]
}
- }
- if ("`allstring'" != "" & "`fmtstring'" != "") {
= if ("" != "" & "" != "") {
opts_exclusive "allstring allstring()"
}
- mata : import_excel_import_file()
(14 vars, 13 obs)
--------------------------------------------------------------------------------------- end import_excel ---
- nobreak {
- local rc = _rc
- if `rc' {
= if 0 {
if ImpExcelCleanUp >= 0 {
mata : import_excel_cleanup()
}
}
- }
- scalar drop ImpExcelCleanUp
- exit `rc'
= exit 0
-------------------------------------------------------------------------------------- end import.ImpExcel ---
- }
- else if `"`subcmd'"' == "fred" {
= else if `"excel"' == "fred" {
ImpFred `macval(0)'
}
- else if `"`subcmd'"' == "hav" {
= else if `"excel"' == "hav" {
ImpHaver `macval(0)'
}
- else if `"`subcmd'"' == "have" {
= else if `"excel"' == "have" {
ImpHaver `macval(0)'
}
- else if `"`subcmd'"' == "haver" {
= else if `"excel"' == "haver" {
ImpHaver `macval(0)'
}
- else if `"`subcmd'"' == "sas" {
= else if `"excel"' == "sas" {
ImpSas `macval(0)'
}
- else if `"`subcmd'"' == "sasxport5" {
= else if `"excel"' == "sasxport5" {
ImpSasxport5 `macval(0)'
}
- else if `"`subcmd'"' == "sasxport8" {
= else if `"excel"' == "sasxport8" {
ImpSasxport8 `macval(0)'
}
- else if `"`subcmd'"' == "sasxport" {
= else if `"excel"' == "sasxport" {
if (_caller() < 16) {
ImpSasxport5 `macval(0)'
}
else {
di as error "invalid syntax"
di as error " specify either {cmd:import sasxport5} or {cmd:import sasxport8}"
exit 198
}
}
- else if `"`subcmd'"' == "shp" {
= else if `"excel"' == "shp" {
ImpShape `macval(0)'
}
- else if `"`subcmd'"' == "spss" {
= else if `"excel"' == "spss" {
ImpSpss `macval(0)'
}
- else {
display as error `"import: unknown subcommand "`subcmd'""'
exit 198
}
I hope this information helps.
Related Posts with Observation Number out of Range r(198) Error
question on line chart outputHello, I created a twoway line chart but the output is too small and I'm not sure how to make it la…
Generate spatial weight matrix by using "spweight"Hi everybody, I am working on Emad A. Shehata's spatial command modules, but I got a trouble in cre…
Tabs for multiple subgroups in one tableI am hoping to run tabs for by various subgroups (different job roles, in this instance). For my tw…
Convert date and time to Stata formatHi all, I would like to convert the following date and time format into Stata format, so that I can…
Replace missing values in panel dataset by the mean, by pasting up, by pasting downHello, I have the following dataset: clear input year id value 1990 1 . 1991 1 . 1992 1 4 1993 1 . …
Subscribe to:
Post Comments (Atom)
0 Response to Observation Number out of Range r(198) Error
Post a Comment