winrats inter-operation

Use this for suggestions about improvements in RATS
TomDoan
Posts: 7731
Joined: Wed Nov 01, 2006 4:36 pm

Re: winrats inter-operation

Unread post by TomDoan »

Can you run the RATS program from the Windows command line directly?
hardmann
Posts: 246
Joined: Sat Feb 26, 2011 9:49 pm

Re: winrats inter-operation

Unread post by hardmann »

Dear Tom:

It successful work only rats with rpf programe file from the Windows command line as follows:

Code: Select all

ratsv10_64.exe C:\python_winrats\mnz_restat_2003.rpf  /run


It does not work with &fname as follows:

Code: Select all

ratsv10_64.exe C:\python_winrats\mnz_restat_2003_py.rpf /fname='C:\python_winrats\LGDP.TXT' /run

I have added envi path of ratsv10_64.exe.

MNZ_RESTAT_2003_PY.out is

Code: Select all

open data &fname
<<<<
## SX22. Expected Type STRING, Got ANY Instead
Best regard
Hardmann
TomDoan
Posts: 7731
Joined: Wed Nov 01, 2006 4:36 pm

Re: winrats inter-operation

Unread post by TomDoan »

That's not how the command line argument works. You need the /D switch:

/Dfname='C:\python_winrats\LGDP.TXT'
hardmann
Posts: 246
Joined: Sat Feb 26, 2011 9:49 pm

Re: winrats inter-operation

Unread post by hardmann »

Dear Tom:

It does not work. I simplified the problem and explained the situation again. I only use the lgdp.txt data file from MZN (2003). The new us_1gdp.rpf file, after reading the data, multiplies it by 100 and saves it as the us_1gdp.xls file, with nothing else. It works normally.
Now change the data file to &fname in us_LGDP_for_command.rpf. The folder is C:\Python-WinRats. The installation folder of winrats had been added to the system's environment variables.

us_Lgdp.rpf is

Code: Select all

*
open data lgdp.txt
calendar(q) 1947
data(format=free,org=columns) 1947:01 1998:02 lgdp
*
set lgdp100 = 100.0*lgdp
open copy us_lgdp.xls
copy(dates,format=xls,org=columns) /  lgdp100
us_LGDP_for_command.rpf is

Code: Select all

* Test for command line or python
*
open data &fname
calendar(q) 1947
data(format=free,org=columns) 1947:01 1998:02 lgdp
*

set lgdp100 = 100.0*lgdp

open copy us_lgdp.xls
copy(dates,format=xls,org=columns) /  lgdp100
Run

Code: Select all

ratsv10_64.exe C:\python_winrats\us_LGDP_for_command.rpf /fname='C:\python_winrats\LGDP.TXT' /run 
or

Code: Select all

ratsv10_64.exe C:\python_winrats\us_lgdp_for_command.rpf /Dfname='C:\python_winrats\LGDP.TXT' /run
in the command line of window. They do not work.

How can I do?

Best Regard
Hardmann
Attachments
lgdp.txt
(3 KiB) Downloaded 291 times
us_lgdp_for_command.rpf
(236 Bytes) Downloaded 321 times
us_lgdp.rpf
(238 Bytes) Downloaded 288 times
hardmann
Posts: 246
Joined: Sat Feb 26, 2011 9:49 pm

Re: winrats inter-operation

Unread post by hardmann »

Dear Tom:

Please help me.

Best Regard
Hardmann
TomDoan
Posts: 7731
Joined: Wed Nov 01, 2006 4:36 pm

Re: winrats inter-operation

Unread post by TomDoan »

Strip the '...' from the data file name argument:

ratsv10_64.exe C:\python_winrats\us_lgdp_for_command.rpf /Dfname=C:\python_winrats\LGDP.TXT /run
TomDoan
Posts: 7731
Joined: Wed Nov 01, 2006 4:36 pm

Re: winrats inter-operation

Unread post by TomDoan »

Version 11 will now allow '....' in the value for the /Dnnnn=value command line option.
hardmann
Posts: 246
Joined: Sat Feb 26, 2011 9:49 pm

Re: winrats inter-operation

Unread post by hardmann »

Dear Tom:

Thanks.I have updated my Winrats to version 11. I have tried the Dfname, it works. However, I try /Dfreq="quarter" /Dstart="1947Q1" to use FREQ and START inside the RATS program. It does not work.How do I set it up in Python and RPF?

I use python to call Winrats, and fname,startdate and enddate are inout parameter.
I take MZN as example.

my python code is:

Code: Select all

import subprocess
rats_path = "C:\Program Files (x86)\Estima\WinRATS Pro 11\\x64"
command = f'{rats_path}/ratsv11_64.exe C:\python_winrats\mnz_restat_2003_py3.rpf /Dfname="lgdp.xlsx" /Dstart="1947Q1" /Dend="1998Q2" /run '
mnz_restat_2003_py3.rpf

Code: Select all

open data &fname
calendar(q) 1947:01
data(format=xlsx,org=columns) &start &end lgdp
It response:
## SX22. Expected Type INTEGER, Got STRING Instead
>>>>&end lgdp

Please Tom help me.

Best regard
Hardmann
PeterF
Posts: 58
Joined: Thu Apr 12, 2012 2:03 pm

Re: winrats inter-operation

Unread post by PeterF »

Dear Hardmann,

in your rpf-file you use the DATA instrction, which expects start and end to be integer variable. But in the python program file, you pass start and end data as a string. Furthermore, for quarterly data you can write 1947:1 for the start and 1998:2 for the end. Thus, deleting in the python command the quotation marks and replacing the Q with the column sign, you should not get the error message anymore.

Best regards
PeterF
TomDoan
Posts: 7731
Joined: Wed Nov 01, 2006 4:36 pm

Re: winrats inter-operation

Unread post by TomDoan »

The & is designed only for parameters where a literal string is expected. It doesn't work with general expressions. Instead, do separate definitions for (say) /DstartYear=1947 /DstartPer=1 and similarly for the end and use startYear:startPer for the start date.
hardmann
Posts: 246
Joined: Sat Feb 26, 2011 9:49 pm

Re: winrats inter-operation

Unread post by hardmann »

Dear Tom:

Thanks. I got it.

Best Regard
Hardmann
TomDoan
Posts: 7731
Joined: Wed Nov 01, 2006 4:36 pm

Re: winrats inter-operation

Unread post by TomDoan »

That's not a bad idea. I will just have to see how hard it would be to make the & prefix resolve to an expression and not just a string.
Post Reply