Error message when running a loop command

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

Error message when running a loop command

morticia
Hello,

I don't have a good understanding of the loop code (yet) and have been given some code to run, that does not work.

The code is as follows:

Vector search=DateSearch1 to DateSearch20/date=VisitDate_1 to VisitDate_2924/
  Found=DateFound1 to DateFound20.
Loop #i=1 to 20.
+  compute #j=search(#i).
+  if (not(sysmis(#j))) found(#i)=date(#j).
End loop.
Execute.

The error warnings are:

>The subscript in a vector reference is missing or otherwise invalid.  The
>subscript must be a positive integer and must not be greater than the length
>of the vector.  The result has been set to the system-missing value.
>Command line: 144  Current case: 1  Current splitfile group: 1

I'd be grateful for any pointers!

Thank you,

morticia
Reply | Threaded
Open this post in threaded view
|

Re: Error message when running a loop command

Rich Ulrich
>
> I don't have a good understanding of the loop code (yet) and have been given
> some code to run, that does not work.
>
> The code is as follows:
>
> Vector search=DateSearch1 to DateSearch20/date=VisitDate_1 to
> VisitDate_2924/
> Found=DateFound1 to DateFound20.
> Loop #i=1 to 20.
> + compute #j=search(#i).
> + if (not(sysmis(#j))) found(#i)=date(#j).
> End loop.
> Execute.
>

Here is one candidate for the problem.

 #j  is set to some value equal to a Datesearch value.
It is used in date(#j), where #j is apparently allowed
to run from 1 to 2924.  Is #j always less than 2924?

--
Rich Ulrich


=====================
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 message when running a loop command

David Marso
Administrator
In reply to this post by morticia
Do FREQs on DateSearch1 to DateSearch20 to verify Rich's suggestion.

On Mon, 11 Apr 2011 14:58:03 -0400, Rich Ulrich <[hidden email]> wrote:

>>
>> I don't have a good understanding of the loop code (yet) and have been given
>> some code to run, that does not work.
>>
>> The code is as follows:
>>
>> Vector search=DateSearch1 to DateSearch20/date=VisitDate_1 to
>> VisitDate_2924/
>> Found=DateFound1 to DateFound20.
>> Loop #i=1 to 20.
>> + compute #j=search(#i).
>> + if (not(sysmis(#j))) found(#i)=date(#j).
>> End loop.
>> Execute.
>>
>
>Here is one candidate for the problem.
>
> #j  is set to some value equal to a Datesearch value.
>It is used in date(#j), where #j is apparently allowed
>to run from 1 to 2924.  Is #j always less than 2924?
>
>--
>Rich Ulrich
>
>
>=====================
>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 message when running a loop command

morticia
<quote author="David Marso">
Do FREQs on DateSearch1 to DateSearch20 to verify Rich's suggestion.

Freqs on DateSearch1 to DateSearch20 yielded a maximum value of 160.

The syntax is checking attendance records - looking at the last date of attendance before a long absence. DateSearch tells me the number of days attended while DateFound records the last date attended. Since it is recording dates without the actual date format, the numbers are very high - in the 22 digits. Could this be the problem?

Thanks!

morticia

Reply | Threaded
Open this post in threaded view
|

Re: Error message when running a loop command

ViAnn Beadle
You've found your problem.

Even with the date format applied, values are stored as seconds from the
start of the Gregorian calendar (October 15, 1582). You could use xdate.day
function to extract day from the variable but that will give you the number
of days since the start of the Gregorian calendar. You could also use the
datediff function to calculate an offset from the 1st day in your file. But
you haven't told us what your goal is. Perhaps your approach is less than
optimal.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
morticia
Sent: Tuesday, April 12, 2011 4:32 PM
To: [hidden email]
Subject: Re: Error message when running a loop command

Do FREQs on DateSearch1 to DateSearch20 to verify Rich's suggestion.

Freqs on DateSearch1 to DateSearch20 yielded a maximum value of 160.

The syntax is checking attendance records - looking at the last date of
attendance before a long absence. DateSearch tells me the number of days
attended while DateFound records the last date attended. Since it is
recording dates without the actual date format, the numbers are very high -
in the 22 digits. Could this be the problem?

Thanks!

morticia



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-message-when-running-a-l
oop-command-tp4296509p4299298.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 message when running a loop command

morticia
ViAnn Beadle wrote
You've found your problem.

Even with the date format applied, values are stored as seconds from the
start of the Gregorian calendar (October 15, 1582). You could use xdate.day
function to extract day from the variable but that will give you the number
of days since the start of the Gregorian calendar. You could also use the
datediff function to calculate an offset from the 1st day in your file. But
you haven't told us what your goal is. Perhaps your approach is less than
optimal.
That makes sense. Thanks!

To answer your question:

The ultimate goal is to define the 1st date of the start of every attendance 'streak'. A break in the streak is defined by a lapse of 540 days or more. I've used SAS to identify the 'streaks'. DateSearch tells me the total number of days attended (there are smaller breaks between dates, but none greater than 540 days) in each streak, while DateFound defines the actual last date of the attendance streak. VisitDate_1 to VisitDate_2924 contains the date information for each visit attended. My goal is to rewrite this loop to give me the first date of attendance in a streak.
Reply | Threaded
Open this post in threaded view
|

Re: Error message when running a loop command

ViAnn Beadle
What is your data structure? Are there multiple dates per case (row of
data)? When you used SAS to identify the streak, how is that represented in
the case?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
morticia
Sent: Wednesday, April 13, 2011 7:27 AM
To: [hidden email]
Subject: Re: Error message when running a loop command

ViAnn Beadle wrote:

>
> You've found your problem.
>
> Even with the date format applied, values are stored as seconds from
> the start of the Gregorian calendar (October 15, 1582). You could use
> xdate.day function to extract day from the variable but that will give
> you the number of days since the start of the Gregorian calendar. You
> could also use the datediff function to calculate an offset from the
> 1st day in your file.
> But
> you haven't told us what your goal is. Perhaps your approach is less
> than optimal.
>

That makes sense. Thanks!

To answer your question:

The ultimate goal is to define the 1st date of the start of every attendance
'streak'. A break in the streak is defined by a lapse of 540 days or more.
I've used SAS to identify the 'streaks'. DateSearch tells me the total
number of days attended (there are smaller breaks between dates, but none
greater than 540 days) in each streak, while DateFound defines the actual
last date of the attendance streak. VisitDate_1 to VisitDate_2924 contains
the date information for each visit attended. My goal is to rewrite this
loop to give me the first date of attendance in a streak.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-message-when-running-a-l
oop-command-tp4296509p4300596.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