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.

Setting dummy values to Integer

Postby bnathan » Mon Dec 19, 2011 10:55 am

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
bnathan
 
Posts: 2
Joined: Fri Dec 16, 2011 2:40 pm
Location: Arlington, VA

Re: Setting dummy values to Integer

Postby TomDoan » Mon Dec 19, 2011 11:40 am

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/
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Setting dummy values to Integer

Postby bnathan » Tue Dec 20, 2011 10:01 am

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
bnathan
 
Posts: 2
Joined: Fri Dec 16, 2011 2:40 pm
Location: Arlington, VA

Re: Setting dummy values to Integer

Postby TomDoan » Tue Dec 20, 2011 10:46 am

RATS doesn't automatically change reals (data) to integers, which is why the FIX function is needed.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 1 guest