Page 1 of 1

How do I read a series whose name is a reserved word?

Posted: Thu Nov 05, 2015 4:19 pm
by macro
For example, this code:

Code: Select all

open haver "C:\Haver\USECON"
    data(format = haver) 1970:1 2015:2 i
close haver
returns an error:

Code: Select all

## IO30. There is no series CONSTANT on the file
presumably because -i- is a reserved keyword. Similarly, this code

Code: Select all

compute lbl = "i"
open haver "C:\Haver\USECON"
    data(format = haver) 1970:1 2015:2 %s(lbl)
close haver
outputs:

Code: Select all

## SX22. Expected Type INTEGER, Got SERIES[REAL] Instead
Assuming I diagnosed the problem correctly, is there a way around this, besides importing the data into Excel, CSV, etc. and reading it into RATS without referring to the name directly?

Since this is an external data source, I can't simply rename the series in the file.

Re: How do I read a series whose name is a reserved word?

Posted: Thu Nov 05, 2015 7:10 pm
by TomDoan
You need to use a different local series name, and reset its label to "I":

Code: Select all

clear myi
label myi
# "I"
open haver "C:\haver\USECON"
cal(q) 1970:1
data(format = haver) 1970:1 2015:2 myi