Error #4030 using VECTOR

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Error #4030 using VECTOR

peter link

Hi SPSSX-L

 

I have written this code that does some comparison of dates.  I’m sure the code is ugly and inefficient, but that isn’t really my question (although pointers are always welcome!), so bear with me here. :-)

 

I am using SPSS v11.5

 

Here is the code.

 

VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

            LOOP #i = 1 to 3 .

            COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                        DO IF (matched eq 1) .

                                    COMPUTE da(#i) = 0 .

                                    COMPUTE db(#i) = 0 .

                        ELSE IF (matched ne 1) .

                                    DO IF (id eq LAG(id) & #la1df eq 0) .

                                                COMPUTE da(#i) = dm(#i) .

                                                COMPUTE db(#i) = dm(#i) .

                                    ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                                IF #df(#i) eq -2  & #ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 1.

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id ne LAG(id)) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0.

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1.

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 1 .

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE .

                                    END IF .

                        ELSE .

                        END IF .                                   

END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .

 

There are many error messages but they are all related.  The error message doesn’t help me much - I have defined a vector!

 

>Error # 4030 in column 10.  Text: #DF

>The operand appearing on the left side of the assignment operator (equals

>sign) is not a known vector name or function name.

>This command not executed.

 

Here is a sample of data

 

data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10) dmatch1(f8) dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .

 

Also, I have many more dates to match, so I’ve tried to modify the code to the data I provided.

 

Try to be nice if, if this is an obvious error with an equally obvious fix.  Thanks for any help!

 

Peter

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Short
Is line 53 missing a (.    
 IF #df(#i) eq -2  & #ld1df ge 4) db(#i) = 1 .
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Short
In reply to this post by peter link
I suggest that following the Create command on line 15 that you remove the / in the following line.
CREATE   lctdd = LEAD(ctdd 1) .
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Marso
Administrator
In reply to this post by peter link
Maybe describe the specifics of what needs to be done rather than expect strangers to debug complicated, uncommented code.  Usually there is a rather simple  elegant answer to most issues. David Short pointed out a few obvious things.  I've been trying to debug a 1000 line MATRIX macro since about 8 AM so excuse my reticence to jump into your code.  Maybe flow chart your logic as a first step.  That might suggest a more jugular approach to your issue.
--

peter link wrote
Hi SPSSX-L



I have written this code that does some comparison of dates.  I'm sure the
code is ugly and inefficient, but that isn't really my question (although
pointers are always welcome!), so bear with me here. :-)



I am using SPSS v11.5



Here is the code.



VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

            LOOP #i = 1 to 3 .

            COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                        DO IF (matched eq 1) .

                                    COMPUTE da(#i) = 0 .

                                    COMPUTE db(#i) = 0 .

                        ELSE IF (matched ne 1) .

                                    DO IF (id eq LAG(id) & #la1df eq 0) .

                                                COMPUTE da(#i) = dm(#i) .

                                                COMPUTE db(#i) = dm(#i) .

                                    ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df
lt 4) db(#i) = 0 .

                                                IF #df(#i) eq -2  & #ld1df
ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df
lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df
ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 1.

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id ne LAG(id)) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0.

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1.

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 1 .

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE .

                                    END IF .

                        ELSE .

                        END IF .

END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .



There are many error messages but they are all related.  The error message
doesn't help me much - I have defined a vector!



>Error # 4030 in column 10.  Text: #DF

>The operand appearing on the left side of the assignment operator (equals

>sign) is not a known vector name or function name.

>This command not executed.



Here is a sample of data



data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10) dmatch1(f8)
dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .



Also, I have many more dates to match, so I've tried to modify the code to
the data I provided.



Try to be nice if, if this is an obvious error with an equally obvious fix.
Thanks for any help!



Peter
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Marso
Administrator
In reply to this post by peter link
OK.  There is ALOT of redundant stuff.  CONSOLIDATE and chart the logic!!!!
You really DON'T need an indent of 7 characters. Try 2-4 MAX.
There are blank lines in between every line.
What values can these variables take?
If 0/1 use Boolean logic whenever possible.
eg:
 IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .
 IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .
 becomes:

COMPUTE da(#I)=  #df(#i) eq -1 AND NOT( #ld1df  ).
Assuming #ld1df   takes values of 0 or 1.

This is repeated in many places and sometimes you lack the # on #ld1df  .

Remove REDUNDANT partial conjunctions
id eq LAG(id) appears everywhere conjoined with another condition.
Yank that out and have it as another DO IF clause.

I could go on and on, but you need to analyze/refactor and resubmit your question.
Nobody here is going to spend an hour trying to sort through this mess and debug your code.
-------------

VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

            LOOP #i = 1 to 3 .

            COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                        DO IF (matched eq 1) .

                                    COMPUTE da(#i) = 0 .

                                    COMPUTE db(#i) = 0 .

                        ELSE IF (matched ne 1) .

                                    DO IF (id eq LAG(id) & #la1df eq 0) .

                                                COMPUTE da(#i) = dm(#i) .

                                                COMPUTE db(#i) = dm(#i) .

                                    ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df
lt 4) db(#i) = 0 .

                                                IF #df(#i) eq -2  & #ld1df
ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df
ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df
lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df
ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 1.

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE IF (id ne LAG(id)) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq
1) da(#i) = 0.

                                                IF (#df(#i) eq -1 & ld1df ne
1) da(#i) = 1.

                                                IF ABS(#df(#i)) ne 1 da(#i)
= 0 .

                                                IF #df(#i) eq 2 db(#i) = 1 .

                                                IF (#df(#i) eq -2 & ld1df lt
4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge
4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i)
= 0 .

                                    ELSE .

                                    END IF .

                        ELSE .

                        END IF .

END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .



There are many error messages but they are all related.  The error message
doesn't help me much - I have defined a vector!



>Error # 4030 in column 10.  Text: #DF

>The operand appearing on the left side of the assignment operator (equals

>sign) is not a known vector name or function name.

>This command not executed.



Here is a sample of data



data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10) dmatch1(f8)
dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .



Also, I have many more dates to match, so I've tried to modify the code to
the data I provided.



Try to be nice if, if this is an obvious error with an equally obvious fix.
Thanks for any help!



Peter

Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

peter link
In reply to this post by David Short
Thanks David Short & David Marso.  There was some paren errors and
inconsistent variable names.  Also, it wasn't my intention for anyone to do
my work for me and debug my code.  I was more looking for insight into the
error message and possible places to look for the error.  Sorry about not
being clearer on that.  And, yes, I realize the code is very inefficient.
The LISTSERV seemed to mangle it, also - again apologies.

After some more work, it seems that CREATE LEAD() causes problems for a
VECTOR COMPUTE inside the LOOP.  For example, this gives the previously
mentioned error message.

>Error # 4030 in column 9.  Text: DF
>The operand appearing on the left side of the assignment operator (equals
>sign) is not a known vector name or function name.
>This command not executed.

VECTOR d = d1 to d47 .
VECTOR df(47) .
COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .
COMPUTE ctdd = CTIME.DAYS(date) .
CREATE lctdd = LEAD(ctdd 1) .
COMPUTE #ld1df = ABS(ctdd - lctdd) .
LOOP #i = 1 to 47 .
COMPUTE df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .
END LOOP .
EXECUTE .

While, this runs without error.

VECTOR d = d1 to d47 .
VECTOR df(47) .
COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .
LOOP #i = 1 to 47 .
COMPUTE df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .
END LOOP .
EXECUTE .

By the way, this by itself, runs without error.

CREATE lctdd = LEAD(ctdd 1) .

Again, I am running v11.5 (I think CREATE LEAD() maybe was new and maybe
that is the issue?  If this is the problem - is there a workaround?

I'm a bit stumped.

Any suggestion is much appreciated.

Thanks.
Peter


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Short
Sent: Wednesday, October 30, 2013 6:23 PM
To: [hidden email]
Subject: Re: [SPSSX-L] Error #4030 using VECTOR

I suggest that following the Create command on line 15 that you remove the /
in the following line.
CREATE   lctdd = LEAD(ctdd 1) .



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-4030-using-VECTOR-tp5722
813p5722815.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

Rich Ulrich
In reply to this post by peter link
In reference to the original question, implied in the SUBJECT line
but not explicitly stated:  What does the error message mean?

Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed.

As to David's comments on the formatting:  Here is another post
where some software is using fancy formatting that is not reproduced
consistently.  When the message is shown to me by Outlook, it has
extra blank lines; when I REPLY to the message, the blanks lines disappear.

As to David's suggestions -- I mostly agree. Don't repeat the IF on
LAG.  Find a way to reduce the other IFs that are repeated.  I would
consider replacing some of those with logical variables that are computed.

However - When I have a bunch of nested, numerical conditions, I check to see
if I can compute a single numerical variable that holds all the combinations
and then use a single RECODE.  That has the prospect of eliminating dozens
of lines of codes, while being easier to proofread and faster when it runs.

--
Rich Ulrich



Date: Wed, 30 Oct 2013 17:39:35 -0700
From: [hidden email]
Subject: Error #4030 using VECTOR
To: [hidden email]

Hi SPSSX-L

 

I have written this code that does some comparison of dates.  I’m sure the code is ugly and inefficient, but that isn’t really my question (although pointers are always welcome!), so bear with me here. :-)

 

I am using SPSS v11.5

 

Here is the code.

 

VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

            LOOP #i = 1 to 3 .

            COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                        DO IF (matched eq 1) .

                                    COMPUTE da(#i) = 0 .

                                    COMPUTE db(#i) = 0 .

                        ELSE IF (matched ne 1) .

                                    DO IF (id eq LAG(id) & #la1df eq 0) .

                                                COMPUTE da(#i) = dm(#i) .

                                                COMPUTE db(#i) = dm(#i) .

                                    ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                                IF #df(#i) eq -2  & #ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                                IF #df(#i) eq 1 da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & #ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 0.

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 1.

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE IF (id ne LAG(id)) .

                                                IF #df(#i) eq 1 da(#i) = 1.

                                                IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0.

                                                IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1.

                                                IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                                IF #df(#i) eq 2 db(#i) = 1 .

                                                IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                                IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                                IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                    ELSE .

                                    END IF .

                        ELSE .

                        END IF .                                   

END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .

 

There are many error messages but they are all related.  The error message doesn’t help me much - I have defined a vector!

 

>Error # 4030 in column 10.  Text: #DF

>The operand appearing on the left side of the assignment operator (equals

>sign) is not a known vector name or function name.

>This command not executed.

 

Here is a sample of data

 

data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10) dmatch1(f8) dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .

 

Also, I have many more dates to match, so I’ve tried to modify the code to the data I provided.

 

Try to be nice if, if this is an obvious error with an equally obvious fix.  Thanks for any help!

 

Peter

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Marso
Administrator
In reply to this post by peter link
Hi Peter,
Simple explanation.
CREATE is not a transformation, it is a procedure and passes the data.
VECTOR definitions go poof after any procedure.
SOLUTION:  Define the VECTOR(s) AFTER CREATE.

NOTE:  in your original code you have a sequence of nested IF..ELSE conditions.
The body of these blocks is identical AFAIKT.  
The only difference is the second conjunct.
I would recast that as something like.
COMPUTE sameID=ID EQ LAG(ID).
+  DO IF sameID.
+    LOOP I=1 TO 4.
+      DO IF (var EQ I).
+          body of code here
+      END IF.
+    END LOOP.
+  ELSE.
+    code for non same id (which also looks identical; except for one Boolean flag)..
+  END IF.
........
HTH, David

peter link wrote
Thanks David Short & David Marso.  There was some paren errors and
inconsistent variable names.  Also, it wasn't my intention for anyone to do
my work for me and debug my code.  I was more looking for insight into the
error message and possible places to look for the error.  Sorry about not
being clearer on that.  And, yes, I realize the code is very inefficient.
The LISTSERV seemed to mangle it, also - again apologies.

After some more work, it seems that CREATE LEAD() causes problems for a
VECTOR COMPUTE inside the LOOP.  For example, this gives the previously
mentioned error message.

>Error # 4030 in column 9.  Text: DF
>The operand appearing on the left side of the assignment operator (equals
>sign) is not a known vector name or function name.
>This command not executed.

VECTOR d = d1 to d47 .
VECTOR df(47) .
COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .
COMPUTE ctdd = CTIME.DAYS(date) .
CREATE lctdd = LEAD(ctdd 1) .
COMPUTE #ld1df = ABS(ctdd - lctdd) .
LOOP #i = 1 to 47 .
COMPUTE df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .
END LOOP .
EXECUTE .

While, this runs without error.

VECTOR d = d1 to d47 .
VECTOR df(47) .
COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .
LOOP #i = 1 to 47 .
COMPUTE df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .
END LOOP .
EXECUTE .

By the way, this by itself, runs without error.

CREATE lctdd = LEAD(ctdd 1) .

Again, I am running v11.5 (I think CREATE LEAD() maybe was new and maybe
that is the issue?  If this is the problem - is there a workaround?

I'm a bit stumped.

Any suggestion is much appreciated.

Thanks.
Peter


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Short
Sent: Wednesday, October 30, 2013 6:23 PM
To: [hidden email]
Subject: Re: [SPSSX-L] Error #4030 using VECTOR

I suggest that following the Create command on line 15 that you remove the /
in the following line.
CREATE   lctdd = LEAD(ctdd 1) .



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-4030-using-VECTOR-tp5722
813p5722815.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

peter link
Wow, that did the trick.  That was not even on my radar.  Very good
information, David.

By the way, with CREATE not being a transformation; it was kind of a poor
choice by SPSS to have it in the "Transform" dialog. :-0

I will try to do better with my Original Posts, if I make any, in the
future.

Thanks for the help, SPSSX-L!

peter

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: Thursday, October 31, 2013 10:19 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Error #4030 using VECTOR

Hi Peter,
Simple explanation.
CREATE is *not* a *transformation*, it is a *procedure *and *passes *the
data.
*VECTOR* definitions *go poof *after *any procedure*.
*SOLUTION*:  Define the VECTOR(s) *AFTER CREATE*.

NOTE:  in your original code you have a sequence of nested IF..ELSE
conditions.
The *body of these blocks is identical* AFAIKT.
The only difference is the second conjunct.
I would recast that as something like.
COMPUTE sameID=ID EQ LAG(ID).
+  DO IF sameID.
+    LOOP I=1 TO 4.
+      DO IF (var EQ I).
+          body of code here
+      END IF.
+    END LOOP.
+  ELSE.
+    code for non same id (which also looks identical; except for one
Boolean flag)..
+  END IF.
........
HTH, David


peter link wrote

> Thanks David Short & David Marso.  There was some paren errors and
> inconsistent variable names.  Also, it wasn't my intention for anyone to
> do
> my work for me and debug my code.  I was more looking for insight into the
> error message and possible places to look for the error.  Sorry about not
> being clearer on that.  And, yes, I realize the code is very inefficient.
> The LISTSERV seemed to mangle it, also - again apologies.
>
> After some more work, it seems that CREATE LEAD() causes problems for a
> VECTOR COMPUTE inside the LOOP.  For example, this gives the previously
> mentioned error message.
>
>>Error # 4030 in column 9.  Text: DF
>>The operand appearing on the left side of the assignment operator (equals
>>sign) is not a known vector name or function name.
>>This command not executed.
>
> VECTOR d = d1 to d47 .
> VECTOR df(47) .
> COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .
> COMPUTE ctdd = CTIME.DAYS(date) .
> CREATE lctdd = LEAD(ctdd 1) .
> COMPUTE #ld1df = ABS(ctdd - lctdd) .
> LOOP #i = 1 to 47 .
> COMPUTE df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .
> END LOOP .
> EXECUTE .
>
> While, this runs without error.
>
> VECTOR d = d1 to d47 .
> VECTOR df(47) .
> COMPUTE #la1df = ABS(CTIME.DAYS(date) - CTIME.DAYS(LAG(date))) .
> LOOP #i = 1 to 47 .
> COMPUTE df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .
> END LOOP .
> EXECUTE .
>
> By the way, this by itself, runs without error.
>
> CREATE lctdd = LEAD(ctdd 1) .
>
> Again, I am running v11.5 (I think CREATE LEAD() maybe was new and maybe
> that is the issue?  If this is the problem - is there a workaround?
>
> I'm a bit stumped.
>
> Any suggestion is much appreciated.
>
> Thanks.
> Peter
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of
> David Short
> Sent: Wednesday, October 30, 2013 6:23 PM
> To:

> SPSSX-L@.UGA

> Subject: Re: [SPSSX-L] Error #4030 using VECTOR
>
> I suggest that following the Create command on line 15 that you remove the
> /
> in the following line.
> CREATE   lctdd = LEAD(ctdd 1) .
>
>
>
> --
> View this message in context:
>
http://spssx-discussion.1045642.n5.nabble.com/Error-4030-using-VECTOR-tp5722
> 813p5722815.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email
me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
abyssum?"
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-4030-using-VECTOR-tp5722
813p5722829.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Marso
Administrator
In reply to this post by Rich Ulrich
"Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed."


Sure it is,  Just the implied variables in the definition go poof after a data pass.
In fact, using 'scratch' vectors is usually the way to go if one does not want them to be permanent.
NOTE:  Scratch vectors behave the same as scratch variables wrt their being 'Left' for subsequent cases.

compare #B to B

DATA LIST FREE / a b c.
BEGIN DATA
1 2 3
END DATA.
VECTOR #A= A TO C /#B (3)/ B(3).
LOOP #=1 TO 3.
COMPUTE #B(#)=#A(#).
COMPUTE  B(#)=#B(#).
END LOOP.
LIST.

       a        b        c       B1       B2       B3
 
    1.00     2.00     3.00     1.00     2.00     3.00
 
 
Number of cases read:  1    Number of cases listed:  1

Rich Ulrich wrote
In reference to the original question, implied in the SUBJECT line
but not explicitly stated:  What does the error message mean?

Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed.

As to David's comments on the formatting:  Here is another post
where some software is using fancy formatting that is not reproduced
consistently.  When the message is shown to me by Outlook, it has
extra blank lines; when I REPLY to the message, the blanks lines disappear.

As to David's suggestions -- I mostly agree. Don't repeat the IF on
LAG.  Find a way to reduce the other IFs that are repeated.  I would
consider replacing some of those with logical variables that are computed.

However - When I have a bunch of nested, numerical conditions, I check to see
if I can compute a single numerical variable that holds all the combinations
and then use a single RECODE.  That has the prospect of eliminating dozens
of lines of codes, while being easier to proofread and faster when it runs.

--
Rich Ulrich


Date: Wed, 30 Oct 2013 17:39:35 -0700
From: [hidden email]
Subject: Error #4030 using VECTOR
To: [hidden email]














Hi SPSSX-L

 

I have written this code that does some comparison of
dates.  I’m sure the code is ugly and inefficient, but that
isn’t really my question (although pointers are always welcome!), so bear
with me here. :-)

 

I am using SPSS v11.5

 

Here is the code.

 

VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) -
CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

           
LOOP #i = 1 to 3 .

           
COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                       
DO IF (matched eq 1) .

                                   
COMPUTE da(#i) = 0 .

                                   
COMPUTE db(#i) = 0 .

                       
ELSE IF (matched ne 1) .

                                   
DO IF (id eq LAG(id) & #la1df eq 0) .

                                               
COMPUTE da(#i) = dm(#i) .

                                               
COMPUTE db(#i) = dm(#i) .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                               
IF #df(#i) eq 1 da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                               
IF #df(#i) eq -2  & #ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                               
IF #df(#i) eq 1 da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 1.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

           
                       
ELSE IF (id ne LAG(id)) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0.

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1.

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 1 .

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE .

                                   
END IF .

                       
ELSE .

                       
END IF
.                                  


END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .

 

There are many error messages but they are all
related.  The error message doesn’t help me much - I have defined a
vector!

 

>Error # 4030
in column 10.  Text: #DF

>The operand
appearing on the left side of the assignment operator (equals

>sign) is not
a known vector name or function name.

>This command
not executed.

 

Here is a sample
of data

 

data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10)
dmatch1(f8) dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .

 

Also, I have
many more dates to match, so I’ve tried to modify the code to the data I
provided.

 

Try to be nice
if, if this is an obvious error with an equally obvious fix.  Thanks for any
help!

 

Peter
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

Bruce Weaver
Administrator
NOTE:  This is intended for scratch variable newbies, not for you Rich!  (I know you are already well aware of this.)  ;-)

David Marso wrote
NOTE:  Scratch vectors behave the same as scratch variables wrt their being 'Left' for subsequent cases.
And of course, another important difference between scratch variables and "normal" numeric variables is that scratch variables are initialized to 0 whereas normal numeric variables are initialized to SYSMIS.  For example...


NEW FILE.
DATASET CLOSE all.

DATA LIST FREE / a1 to a3.
BEGIN DATA
1 2 3
4 5 6
7 8 9
2 4 6
3 5 7
END DATA.
VECTOR B(3).
LIST.
      a1       a2       a3       B1       B2       B3
 
    1.00     2.00     3.00      .        .        .
    4.00     5.00     6.00      .        .        .
    7.00     8.00     9.00      .        .        .
    2.00     4.00     6.00      .        .        .
    3.00     5.00     7.00      .        .        .
 
 Number of cases read:  5    Number of cases listed:  5

* Notice that B1 to B3 are initialized to SYSMIS.

VECTOR B = B1 to B3 / #B(3).
LOOP #i = 1 to 3.
- COMPUTE B(#i) = #B(#i). /* Assign #B(#i) to B(#i) so its value can be listed.
END LOOP.
LIST.
      a1       a2       a3       B1       B2       B3
 
    1.00     2.00     3.00      .00      .00      .00
    4.00     5.00     6.00      .00      .00      .00
    7.00     8.00     9.00      .00      .00      .00
    2.00     4.00     6.00      .00      .00      .00
    3.00     5.00     7.00      .00      .00      .00
 
 Number of cases read:  5    Number of cases listed:  5

* Notice that #B1 to #B3 are initialized to 0.

* Now show that values of scratch variables carry over to subsequent cases,
* as pointed out by David.

VECTOR C(3) / #C(3).
LOOP #i = 1 to 3.
- IF $CaseNum EQ 2 #C(#i) = #i. /* Assign value of #i to #C(#i) on row 2.
- COMPUTE C(#i) = #C(#i). /* Assign #C(#i) to C(#i) so its value can be listed.
END LOOP.
LIST.
      a1       a2       a3       B1       B2       B3       C1       C2       C3
 
    1.00     2.00     3.00      .00      .00      .00      .00      .00      .00
    4.00     5.00     6.00      .00      .00      .00     1.00     2.00     3.00
    7.00     8.00     9.00      .00      .00      .00     1.00     2.00     3.00
    2.00     4.00     6.00      .00      .00      .00     1.00     2.00     3.00
    3.00     5.00     7.00      .00      .00      .00     1.00     2.00     3.00
 
 Number of cases read:  5    Number of cases listed:  5

* Notice that after the values of #C1 to #C3 are changed on row 2,
* those new values are carried over to subsequent rows.


David Marso wrote
"Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed."


Sure it is,  Just the implied variables in the definition go poof after a data pass.
In fact, using 'scratch' vectors is usually the way to go if one does not want them to be permanent.
NOTE:  Scratch vectors behave the same as scratch variables wrt their being 'Left' for subsequent cases.

compare #B to B

DATA LIST FREE / a b c.
BEGIN DATA
1 2 3
END DATA.
VECTOR #A= A TO C /#B (3)/ B(3).
LOOP #=1 TO 3.
COMPUTE #B(#)=#A(#).
COMPUTE  B(#)=#B(#).
END LOOP.
LIST.

       a        b        c       B1       B2       B3
 
    1.00     2.00     3.00     1.00     2.00     3.00
 
 
Number of cases read:  1    Number of cases listed:  1

Rich Ulrich wrote
In reference to the original question, implied in the SUBJECT line
but not explicitly stated:  What does the error message mean?

Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed.

As to David's comments on the formatting:  Here is another post
where some software is using fancy formatting that is not reproduced
consistently.  When the message is shown to me by Outlook, it has
extra blank lines; when I REPLY to the message, the blanks lines disappear.

As to David's suggestions -- I mostly agree. Don't repeat the IF on
LAG.  Find a way to reduce the other IFs that are repeated.  I would
consider replacing some of those with logical variables that are computed.

However - When I have a bunch of nested, numerical conditions, I check to see
if I can compute a single numerical variable that holds all the combinations
and then use a single RECODE.  That has the prospect of eliminating dozens
of lines of codes, while being easier to proofread and faster when it runs.

--
Rich Ulrich


Date: Wed, 30 Oct 2013 17:39:35 -0700
From: [hidden email]
Subject: Error #4030 using VECTOR
To: [hidden email]














Hi SPSSX-L

 

I have written this code that does some comparison of
dates.  I’m sure the code is ugly and inefficient, but that
isn’t really my question (although pointers are always welcome!), so bear
with me here. :-)

 

I am using SPSS v11.5

 

Here is the code.

 

VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) -
CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

           
LOOP #i = 1 to 3 .

           
COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                       
DO IF (matched eq 1) .

                                   
COMPUTE da(#i) = 0 .

                                   
COMPUTE db(#i) = 0 .

                       
ELSE IF (matched ne 1) .

                                   
DO IF (id eq LAG(id) & #la1df eq 0) .

                                               
COMPUTE da(#i) = dm(#i) .

                                               
COMPUTE db(#i) = dm(#i) .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                               
IF #df(#i) eq 1 da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                               
IF #df(#i) eq -2  & #ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                               
IF #df(#i) eq 1 da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 1.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

           
                       
ELSE IF (id ne LAG(id)) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0.

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1.

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 1 .

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE .

                                   
END IF .

                       
ELSE .

                       
END IF
.                                  


END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .

 

There are many error messages but they are all
related.  The error message doesn’t help me much - I have defined a
vector!

 

>Error # 4030
in column 10.  Text: #DF

>The operand
appearing on the left side of the assignment operator (equals

>sign) is not
a known vector name or function name.

>This command
not executed.

 

Here is a sample
of data

 

data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10)
dmatch1(f8) dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .

 

Also, I have
many more dates to match, so I’ve tried to modify the code to the data I
provided.

 

Try to be nice
if, if this is an obvious error with an equally obvious fix.  Thanks for any
help!

 

Peter
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Error #4030 using VECTOR

David Marso
Administrator


I will add :
Scratch string variables are initialized to a string of blanks.

DATA LIST FREE / a .
BEGIN DATA
1 2 3 4 5 6
END DATA.
STRING str (a3).
STRING #str(A3).
DO IF $CASENUM=2.
+  COMPUTE #str="ABC".
END IF.
COMPUTE str=#str.
LIST.
       a str
 
    1.00
    2.00 ABC
    3.00 ABC
    4.00 ABC
    5.00 ABC
    6.00 ABC
 
 
Number of cases read:  6    Number of cases listed:  6
 
Bruce Weaver wrote
NOTE:  This is intended for scratch variable newbies, not for you Rich!  (I know you are already well aware of this.)  ;-)

David Marso wrote
NOTE:  Scratch vectors behave the same as scratch variables wrt their being 'Left' for subsequent cases.
And of course, another important difference between scratch variables and "normal" numeric variables is that scratch variables are initialized to 0 whereas normal numeric variables are initialized to SYSMIS.  For example...


NEW FILE.
DATASET CLOSE all.

DATA LIST FREE / a1 to a3.
BEGIN DATA
1 2 3
4 5 6
7 8 9
2 4 6
3 5 7
END DATA.
VECTOR B(3).
LIST.
      a1       a2       a3       B1       B2       B3
 
    1.00     2.00     3.00      .        .        .
    4.00     5.00     6.00      .        .        .
    7.00     8.00     9.00      .        .        .
    2.00     4.00     6.00      .        .        .
    3.00     5.00     7.00      .        .        .
 
 Number of cases read:  5    Number of cases listed:  5

* Notice that B1 to B3 are initialized to SYSMIS.

VECTOR B = B1 to B3 / #B(3).
LOOP #i = 1 to 3.
- COMPUTE B(#i) = #B(#i). /* Assign #B(#i) to B(#i) so its value can be listed.
END LOOP.
LIST.
      a1       a2       a3       B1       B2       B3
 
    1.00     2.00     3.00      .00      .00      .00
    4.00     5.00     6.00      .00      .00      .00
    7.00     8.00     9.00      .00      .00      .00
    2.00     4.00     6.00      .00      .00      .00
    3.00     5.00     7.00      .00      .00      .00
 
 Number of cases read:  5    Number of cases listed:  5

* Notice that #B1 to #B3 are initialized to 0.

* Now show that values of scratch variables carry over to subsequent cases,
* as pointed out by David.

VECTOR C(3) / #C(3).
LOOP #i = 1 to 3.
- IF $CaseNum EQ 2 #C(#i) = #i. /* Assign value of #i to #C(#i) on row 2.
- COMPUTE C(#i) = #C(#i). /* Assign #C(#i) to C(#i) so its value can be listed.
END LOOP.
LIST.
      a1       a2       a3       B1       B2       B3       C1       C2       C3
 
    1.00     2.00     3.00      .00      .00      .00      .00      .00      .00
    4.00     5.00     6.00      .00      .00      .00     1.00     2.00     3.00
    7.00     8.00     9.00      .00      .00      .00     1.00     2.00     3.00
    2.00     4.00     6.00      .00      .00      .00     1.00     2.00     3.00
    3.00     5.00     7.00      .00      .00      .00     1.00     2.00     3.00
 
 Number of cases read:  5    Number of cases listed:  5

* Notice that after the values of #C1 to #C3 are changed on row 2,
* those new values are carried over to subsequent rows.


David Marso wrote
"Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed."


Sure it is,  Just the implied variables in the definition go poof after a data pass.
In fact, using 'scratch' vectors is usually the way to go if one does not want them to be permanent.
NOTE:  Scratch vectors behave the same as scratch variables wrt their being 'Left' for subsequent cases.

compare #B to B

DATA LIST FREE / a b c.
BEGIN DATA
1 2 3
END DATA.
VECTOR #A= A TO C /#B (3)/ B(3).
LOOP #=1 TO 3.
COMPUTE #B(#)=#A(#).
COMPUTE  B(#)=#B(#).
END LOOP.
LIST.

       a        b        c       B1       B2       B3
 
    1.00     2.00     3.00     1.00     2.00     3.00
 
 
Number of cases read:  1    Number of cases listed:  1

Rich Ulrich wrote
In reference to the original question, implied in the SUBJECT line
but not explicitly stated:  What does the error message mean?

Since the definition of a VECTOR does not exist beyond the next
execution, it makes some sense that using a temporary name
assignment like  "VECTOR #DF(3)" is not allowed.

As to David's comments on the formatting:  Here is another post
where some software is using fancy formatting that is not reproduced
consistently.  When the message is shown to me by Outlook, it has
extra blank lines; when I REPLY to the message, the blanks lines disappear.

As to David's suggestions -- I mostly agree. Don't repeat the IF on
LAG.  Find a way to reduce the other IFs that are repeated.  I would
consider replacing some of those with logical variables that are computed.

However - When I have a bunch of nested, numerical conditions, I check to see
if I can compute a single numerical variable that holds all the combinations
and then use a single RECODE.  That has the prospect of eliminating dozens
of lines of codes, while being easier to proofread and faster when it runs.

--
Rich Ulrich


Date: Wed, 30 Oct 2013 17:39:35 -0700
From: [hidden email]
Subject: Error #4030 using VECTOR
To: [hidden email]














Hi SPSSX-L

 

I have written this code that does some comparison of
dates.  I’m sure the code is ugly and inefficient, but that
isn’t really my question (although pointers are always welcome!), so bear
with me here. :-)

 

I am using SPSS v11.5

 

Here is the code.

 

VECTOR d = d1 to d3 .

VECTOR dm = dmatch1 to dmatch3 .

VECTOR #df(3) .

VECTOR da(3) .

VECTOR db(3) .

COMPUTE #la1df = ABS(CTIME.DAYS(date) -
CTIME.DAYS(LAG(date))) .

COMPUTE ctdd = CTIME.DAYS(date) .

CREATE

  /lctdd = LEAD(ctdd 1) .

COMPUTE #ld1df = ABS(ctdd - lctdd) .

           
LOOP #i = 1 to 3 .

           
COMPUTE #df(#i) = CTIME.DAYS(date) - CTIME.DAYS(d(#i)) .

                       
DO IF (matched eq 1) .

                                   
COMPUTE da(#i) = 0 .

                                   
COMPUTE db(#i) = 0 .

                       
ELSE IF (matched ne 1) .

                                   
DO IF (id eq LAG(id) & #la1df eq 0) .

                                               
COMPUTE da(#i) = dm(#i) .

                                               
COMPUTE db(#i) = dm(#i) .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 1) .

                                               
IF #df(#i) eq 1 da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                               
IF #df(#i) eq -2  & #ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 2) .

                                               
IF #df(#i) eq 1 da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & #ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & #ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 3) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df eq 4) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 0.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE IF (id eq LAG(id) & #la1df gt 4) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0 .

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 1.

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

           
                       
ELSE IF (id ne LAG(id)) .

                                               
IF #df(#i) eq 1 da(#i) = 1.

                                               
IF (#df(#i) eq -1 & ld1df eq 1) da(#i) = 0.

                                               
IF (#df(#i) eq -1 & ld1df ne 1) da(#i) = 1.

                                               
IF ABS(#df(#i)) ne 1 da(#i) = 0 .

                                               
IF #df(#i) eq 2 db(#i) = 1 .

                                               
IF (#df(#i) eq -2 & ld1df lt 4) db(#i) = 0 .

                                               
IF (#df(#i) eq -2 & ld1df ge 4) db(#i) = 1 .

                                               
IF ABS(#df(#i)) ne 2 db(#i) = 0 .

                                   
ELSE .

                                   
END IF .

                       
ELSE .

                       
END IF
.                                  


END LOOP .

COMPUTE match1 = sum(da1 to da3) .

COMPUTE match2 = sum(db1 to db3) .

COMPUTE mwithin2 = sum(matched,match1,match2) .

EXECUTE .

 

There are many error messages but they are all
related.  The error message doesn’t help me much - I have defined a
vector!

 

>Error # 4030
in column 10.  Text: #DF

>The operand
appearing on the left side of the assignment operator (equals

>sign) is not
a known vector name or function name.

>This command
not executed.

 

Here is a sample
of data

 

data list list

/id(a6) date(adate10) d1(adate10) d2(adate10) d3(adate10)
dmatch1(f8) dmatch2(f8) dmatch3(f8) matched(f8).

begin data .

GA006 05/16/2013 02/23/2012 03/08/2012 03/15/2012 0 0 1 1

GA006 05/23/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA006 05/31/2013 02/23/2012 03/08/2012 03/15/2012 0 0 0 0

GA007 04/18/2013 02/24/2012 03/09/2012 03/16/2012 1 0 0 1

GA007 04/25/2013 02/24/2012 03/09/2012 03/16/2012 0 0 0 0

GA007 05/08/2013 02/24/2012 03/09/2012 03/16/2012 0 1 0 1

end data .

 

Also, I have
many more dates to match, so I’ve tried to modify the code to the data I
provided.

 

Try to be nice
if, if this is an obvious error with an equally obvious fix.  Thanks for any
help!

 

Peter
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"