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

For questions and discussion related to reading in and working with data.
macro
Posts: 70
Joined: Thu Jul 16, 2015 3:01 pm

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

Unread post 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.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

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

Unread post 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
Post Reply