Page 1 of 1

Setting dummy values to Integer

Posted: Mon Dec 19, 2011 9:55 am
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.

Re: Setting dummy values to Integer

Posted: Mon Dec 19, 2011 10:40 am
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/

Re: Setting dummy values to Integer

Posted: Tue Dec 20, 2011 9:01 am
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.

Re: Setting dummy values to Integer

Posted: Tue Dec 20, 2011 9:46 am
by TomDoan
RATS doesn't automatically change reals (data) to integers, which is why the FIX function is needed.