Error 4316 when using a loop counter

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

hugo
Posts: 2
Joined: Wed Apr 04, 2012 9:01 am

Error 4316 when using a loop counter

Postby hugo » Wed Apr 04, 2012 9:27 am

In below code the line starting with "COMPUTE VAR2" throws
ERROR 4316, error text says something like
number of cases in the function LAG is invalid, has to be a positive constant value, not-null

From my understanding the code in this line should resolve to exactly the same statement as in the line starting with "COMPUTE VAR1" which is executed without error.


*code start---------------------------------------------------------------------------------

COMPUTE VAR1 = XDATE.TDAY(TRX_DATE) - XDATE.TDAY(LAG(TRX_DATE,1)).

LOOP #i = 1 TO 1. *set end of loop to 1 for debuging
*DO IF XDATE.TDAY(TRX_DATE) - XDATE.TDAY(LAG(TRX_DATE,#i)) < 360.
COMPUTE VAR2 = XDATE.TDAY(TRX_DATE) - XDATE.TDAY(LAG(TRX_DATE,#i)).
*END IF.
COMPUTE VAR3 = #i.
END LOOP.
EXECUTE.

*code end---------------------------------------------------------------------------------
hugo
Posts: 2
Joined: Wed Apr 04, 2012 9:01 am

Error 4316 when using a loop counter - sample data & code

Postby hugo » Wed Apr 04, 2012 12:33 pm

Here's some code with sample data which demonstartes the error:

Code: Select all

DATA LIST FREE / VAR1 (F1.0).
BEGIN DATA
1
2
3
4
5
END DATA.
EXECUTE.

COMPUTE VAR2 = LAG(VAR1,1).

LOOP #i = 1 TO 1.
COMPUTE VAR3 = LAG(VAR1,#i).
COMPUTE VAR4 = #i.
END LOOP.
EXECUTE.

Who is online

Users browsing this forum: No registered users and 1 guest

cron