Setting dummy values to Integer

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
bnathan
Posts: 2
Joined: Fri Dec 16, 2011 1:40 pm

Setting dummy values to Integer

Unread post by bnathan »

Hello,
I'm trying to teach myself RATS and I am struggling with a while loop. Borrowing from some code in the Reference Manual, I've gotten to:

Code: Select all

compute countq1=0, i=0, sumq1=0.0
while countq1<17 {
compute i=i+1
if q1dummy(i)>0
compute sumq1=sumq1+lnagg(i),countq1=countq1+q1dummy(i)
}
endwhile
display sumq1 countq1 i
The current hurdle is when I run this, I get the message:
## SX22. Expected Type INTEGER, Got REAL Instead
>>>>countq1+q1dummy(i)<<<<

I assume I need to set my quarter dummy variables to integers. Any help solving this is greatly appreciated. If you see any clear problems/mistakes you'd like to point out, please don't be shy and thanks in advance.
Sincerely,
Bryan
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Setting dummy values to Integer

Unread post by TomDoan »

You need to use FIX(...) to downgrade the real-valued dummy to an integer.

compute sumq1=sumq1+lnagg(i),countq1=countq1+fix(q1dummy(i))

However, wouldn't countq1=countq1+1 work as well? Is the dummy ever taking a value other than 0 or 1/
bnathan
Posts: 2
Joined: Fri Dec 16, 2011 1:40 pm

Re: Setting dummy values to Integer

Unread post by bnathan »

Thanks, Tom. That worked well.

The dummy never takes a value other than 1 or 0. I'm not sure why I needed to fix anything.
Sincerely,
Bryan
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Setting dummy values to Integer

Unread post by TomDoan »

RATS doesn't automatically change reals (data) to integers, which is why the FIX function is needed.
Post Reply