Opening a data file within a dofor loop
Opening a data file within a dofor loop
Hello,
I am trying to open a data file within a dofor loop. When I run the code outside of a loop, it works fine, but when it is inside the loop, upon my first attempt to use one of the variables from the file, i get the syntax error message "##SX11 Identifier is not recognizable"
--------------------------------------------
declare string str
dofor str = "aaa" "bbb" "ccc"
open data "C:\myfile.xls"
data(format=xls,org=columns)
close
print 1 5 var1
## SX11. Identifier var1 is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>print 1 5 var1<<<<
end dofor str_mo
## SX21. A END or } Here is Unneeded or Unexpected
--------------------------------------------------------------------
Thanks in advance,
-CP
I am trying to open a data file within a dofor loop. When I run the code outside of a loop, it works fine, but when it is inside the loop, upon my first attempt to use one of the variables from the file, i get the syntax error message "##SX11 Identifier is not recognizable"
--------------------------------------------
declare string str
dofor str = "aaa" "bbb" "ccc"
open data "C:\myfile.xls"
data(format=xls,org=columns)
close
print 1 5 var1
## SX11. Identifier var1 is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>print 1 5 var1<<<<
end dofor str_mo
## SX21. A END or } Here is Unneeded or Unexpected
--------------------------------------------------------------------
Thanks in advance,
-CP
Re: Opening a data file within a dofor loop
If the DATA instruction were outside of a loop, the VAR1 would be created by the DATA instruction before it was needed by the PRINT. Inside the loop, however, the DATA won't be executed until the loop is run, and the PRINT needs to be interpreted before that can happen. At that point, VAR1 isn't defined. Since you apparently know what (at least some of the) series are going to be created, you can avoid this problem by puttingcap wrote:Hello,
I am trying to open a data file within a dofor loop. When I run the code outside of a loop, it works fine, but when it is inside the loop, upon my first attempt to use one of the variables from the file, i get the syntax error message "##SX11 Identifier is not recognizable"
--------------------------------------------Thanks in advance,Code: Select all
declare string str dofor str = "aaa" "bbb" "ccc" open data "C:\myfile.xls" data(format=xls,org=columns) close print 1 5 var1 ## SX11. Identifier var1 is Not Recognizable. Incorrect Option Field or Parameter Order? >>>>print 1 5 var1<<<< end dofor str_mo ## SX21. A END or } Here is Unneeded or Unexpected
-CP
Code: Select all
DECLARE SERIES VAR1 (and any others you might need)