Page 1 of 1

DOFOR Loop Question

Posted: Mon Jan 27, 2014 9:00 pm
by timduy
If I write this code:

COMPUTE X = PORT941NA(2007:12)
DISPLAY X

I get what I expect:

1041.50000

If I place it inside a DOFOR loop:

DOFOR JJ = PORT941NA PITT342NA MINN427NA CHIC917NA AUST448NA PHOE004NA DENV708NA NASH947NA OKLA440NA
COMPUTE X = JJ(2007:12)
DISPLAY X
END DOFOR JJ

I get this:

## SX17. Missing Operator or Adjacent Operands
>>>> COMPUTE X = JJ(<<<<

So I can I identify just one entry in the DOFOR loop?

Thank you!

Re: DOFOR Loop Question

Posted: Mon Jan 27, 2014 11:20 pm
by TomDoan
By default, the DOFOR index is an INTEGER, which in this case will run over the "handles" for the series. To pull out an entry from a series you need to add a "cast" to the SERIES type:

COMPUTE X = ([series]JJ)(2007:12)

Re: DOFOR Loop Question

Posted: Tue Jan 28, 2014 11:28 am
by timduy
Again, thank you!