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.