Page 1 of 1
Saving .rat Files
Posted: Wed Mar 19, 2014 12:49 pm
by fannman93
I am required for an assignment to generate series and save the output as a .rat file. I have tried saving the output window as a Rating System File. I then attempt to read in the data in a new programme file to work with it:
all 500
open "C:\Users\Michael\Dropbox\College\3rd Year Semester 2\Econ Fin\RATS\Assignments\New folder\mydata1"
data(for=rats) / x y z
print
However when I do this I am only returned the column headings without the data. Is there a different method I should be using? Any help would be appreciated!
Re: Saving .rat Files
Posted: Wed Mar 19, 2014 1:16 pm
by TomDoan
"Rating System File" is the description for another program (I don't even know which) that uses the .RAT extension. What steps did you follow in creating the data? With 500 data points, it sounds like it was randomly generated. If you've created series X, Y and Z and want to create a RATS format data file from them, you can do
open copy myfile.rat
copy(format=rats) / x y z
or you can do the menu operation "View-Series Window", select the series, and do "File-Export" (or use the Export toolbar or the right-click menu "Export" operation) and select "RATS Data Files(*.RAT)" as the target format.
Re: Saving .rat Files
Posted: Wed Mar 19, 2014 1:37 pm
by fannman93
TomDoan wrote:"Rating System File" is the description for another program (I don't even know which) that uses the .RAT extension. What steps did you follow in creating the data? With 500 data points, it sounds like it was randomly generated. If you've created series X, Y and Z and want to create a RATS format data file from them, you can do
open copy myfile.rat
copy(format=rats) / x y z
or you can do the menu operation "View-Series Window", select the series, and do "File-Export" (or use the Export toolbar or the right-click menu "Export" operation) and select "RATS Data Files(*.RAT)" as the target format.
That's a huge help thanks a million. Just one more question. Having converted the file to rats format:
open copy data.txt
copy(format=rats) / x y z
How do I then save this so I have a RATS data file to read in at a later date?
Re: Saving .rat Files
Posted: Wed Mar 19, 2014 1:45 pm
by TomDoan
I'm confused about what you're doing. Do you already have the data in a text file? data.txt would be the name for a text file, not a RATS format file (which should have a .rat extension). copy(format=rats) takes data already in RATS and creates a RATS format file from it.
Re: Saving .rat Files
Posted: Wed Mar 19, 2014 1:56 pm
by fannman93
TomDoan wrote:I'm confused about what you're doing. Do you already have the data in a text file? data.txt would be the name for a text file, not a RATS format file (which should have a .rat extension). copy(format=rats) takes data already in RATS and creates a RATS format file from it.
What I did was generate 3 series:
all 500
set x = 0
do i=1,500
set x 2 * = 1 + x{1} + %ran(1)
end do
all 500
set y = 0
do i=1,500
set y 2 * = 1.0 + 0.9*y{1} + %ran(1)
end do
all 500
set z = 0
do i=1,500
set z 2 * = 1.0 + z{1} + %ran(1)
end do
print
I then saved the output window as a text file (data.txt) and converted it to rats format as you outline. I now want to save this data as a rats file on my computer so I can submit it as part of an assignment.
Re: Saving .rat Files
Posted: Wed Mar 19, 2014 2:54 pm
by TomDoan
First of all, you don't have to keep repeating ALL 500. Once is enough. Also a SET instruction has an implied loop over the entries, so you don't need those DO I=1,500 loops.
all 500
set(first=0.0) x = 1+x{1}+%ran(1)
set(first=0.0) y = 1.0 + 0.9*y{1} + %ran(1)
set(first=0.0) z = 1.0 + z{1} + %ran(1)
will generate your three series. See, for example, WINTDP374.RPF in the Wooldridge Introduction examples which has a fairly lengthy description of how this works. (There are similar examples in Diebold, Hamilton, Gujarati, Hayashi and Johnston).
If what you want is a RATS format data file, then all you need to add is
open copy myfile.rat
copy(format=rats) / x y z
which will create MYFILE.RAT. You might want to add a SEED instruction before the first SET (see the description in the Wooldridge example) and save the program, but that's a separate file (which should be saved as an .RPF for "RATS Program File"). An RPF is a text file that you can open with anything that can display a text file. A RATS data file is binary, and only can be opened with RATS or RATSData.