select records across a set of variables which meet a condition

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

select records across a set of variables which meet a condition

wsu_wright
The data set contains student hold information including a hold code
(e.g., NF = no fee paid) and a start & end date., there are 20 possible
hold events for each student record.

(data layout)
ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
hold_start20, hold_edate20

12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
01/13/2011, 11/1/2011
57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099

I need to select records (or create a binary denoting the event) in
which there is a 'SO' hold and the end date is equal to or greater than
the system time.

I suspect I need to perform a loop across the 20 possible sets grabbing
the 'SO' if it exist & the end date, I could then create a new column
with each of these (hold & edate when SO occurs) & then select based on
$time but not sure.  As always, any help would be greatly appreciated.

Thanks in advance.

David

=====================
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: select records across a set of variables which meet a condition

Bruce Weaver
Administrator
Hi David.  This can probably be done with VECTOR and LOOP, or DO-REPEAT.  But I wonder if it would not be much simpler to restructure the data (with VARSTOCASES) to have multiple rows per ID, with an Index variable to indicate the hold code number.  The variables would be:

ID, Index, hold_code, hold_sdate, hold_edate

On this restructured data set, flag cases where hold_code EQ 'SO' and hold_edate GT $time.  

compute SO_flag = (hold_code EQ 'SO') and (hold_edate GT $time).

If you need to stick this flag variable back into the original wide file, use AGGREGATE to reduce to one row, keeping the MAX value of SO_flag for each ID, then merge that file (via MATCH FILES) with the original.

HTH.

David Wright-6 wrote
The data set contains student hold information including a hold code
(e.g., NF = no fee paid) and a start & end date., there are 20 possible
hold events for each student record.

(data layout)
ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
hold_start20, hold_edate20

12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
01/13/2011, 11/1/2011
57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099

I need to select records (or create a binary denoting the event) in
which there is a 'SO' hold and the end date is equal to or greater than
the system time.

I suspect I need to perform a loop across the 20 possible sets grabbing
the 'SO' if it exist & the end date, I could then create a new column
with each of these (hold & edate when SO occurs) & then select based on
$time but not sure.  As always, any help would be greatly appreciated.

Thanks in advance.

David

=====================
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
--
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: select records across a set of variables which meet a condition

Garry Gelade
In reply to this post by wsu_wright
Hi David

The following will flag records containing SO.

COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).

If one or more hold codes = SO, flag is set to 1, if none contain SO, flag is set to 0.

Then it is easy to check if the flagged records meet your other conditions.

Garry Gelade
Business Analytic Ltd.
*=================================================================================================

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wright
Sent: 07 April 2011 11:41
To: [hidden email]
Subject: select records across a set of variables which meet a condition

The data set contains student hold information including a hold code
(e.g., NF = no fee paid) and a start & end date., there are 20 possible
hold events for each student record.

(data layout)
ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
hold_start20, hold_edate20

12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
01/13/2011, 11/1/2011
57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099

I need to select records (or create a binary denoting the event) in
which there is a 'SO' hold and the end date is equal to or greater than
the system time.

I suspect I need to perform a loop across the 20 possible sets grabbing
the 'SO' if it exist & the end date, I could then create a new column
with each of these (hold & edate when SO occurs) & then select based on
$time but not sure.  As always, any help would be greatly appreciated.

Thanks in advance.

David

=====================
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: select records across a set of variables which meet a condition

Bruce Weaver
Administrator
Hi Garry.  Your ANY method was the first thing that occurred to me too, and that's what I would have suggested were it not for the additional need to check on whether the end time for that particular hold is greater than or equal to $TIME.  That second part seemed much easier to me with a LONG file format, where there's only one end date per row.  Just out of curiosity, how would you do it with the original WIDE file?

Cheers,
Bruce


Garry Gelade wrote
Hi David

The following will flag records containing SO.

COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).

If one or more hold codes = SO, flag is set to 1, if none contain SO, flag is set to 0.

Then it is easy to check if the flagged records meet your other conditions.

Garry Gelade
Business Analytic Ltd.
*=================================================================================================

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wright
Sent: 07 April 2011 11:41
To: [hidden email]
Subject: select records across a set of variables which meet a condition

The data set contains student hold information including a hold code
(e.g., NF = no fee paid) and a start & end date., there are 20 possible
hold events for each student record.

(data layout)
ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
hold_start20, hold_edate20

12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
01/13/2011, 11/1/2011
57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099

I need to select records (or create a binary denoting the event) in
which there is a 'SO' hold and the end date is equal to or greater than
the system time.

I suspect I need to perform a loop across the 20 possible sets grabbing
the 'SO' if it exist & the end date, I could then create a new column
with each of these (hold & edate when SO occurs) & then select based on
$time but not sure.  As always, any help would be greatly appreciated.

Thanks in advance.

David

=====================
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
--
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: select records across a set of variables which meet a condition

wsu_wright
In reply to this post by wsu_wright
Bruce & Garry,

Thanks for your responses.  They got me thinking, with Garry's compute &
Bruce's hint at the Do Repeat, I could get around both the vector/loop &
casestovars by the following:


do repeat
     holdc=hold_code1 hold_code2 hold_code3  hold_code4 hold_code5
hold_code6 hold_code7 hold_code8 hold_code9 hold_code10
     hold_code11 hold_code12 hold_code13 hold_code14 hold_code15
hold_code16 hold_code17 hold_code18 hold_code19 hold_code20
     /holde=hold_edate1 hold_edate2 hold_edate3  hold_edate4 hold_edate5
hold_edate6 hold_edate7 hold_edate8 hold_edate9 hold_edate10
         hold_edate11 hold_edate12 hold_edate13 hold_edate14
hold_edate15 hold_edate16 hold_edate17 hold_edate18 hold_edate19
hold_edate20.
if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
end repeat.
select if (hold_flag=1).


Thanks again for all your assistance, without your suggestions I'd still
be stuck.

David




On Thu, Apr 7, 2011 at 9:55 AM, Bruce Weaver wrote:

> Hi David.  This can probably be done with VECTOR and LOOP, or
> DO-REPEAT.  But
> I wonder if it would not be much simpler to restructure the data (with
> VARSTOCASES) to have multiple rows per ID, with an Index variable to
> indicate the hold code number.  The variables would be:
>
> ID, Index, hold_code, hold_sdate, hold_edate
>
> On this restructured data set, flag cases where hold_code EQ 'SO' and
> hold_edate GT $time.
>
> compute SO_flag = (hold_code EQ 'SO') and (hold_edate GT $time).
>
> If you need to stick this flag variable back into the original wide
> file,
> use AGGREGATE to reduce to one row, keeping the MAX value of SO_flag
> for
> each ID, then merge that file (via MATCH FILES) with the original.
>
> HTH.
>

On Thu, Apr 7, 2011 at 11:10 AM, Garry Gelade wrote:

> Hi David
>
> The following will flag records containing SO.
>
> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>
> If one or more hold codes = SO, flag is set to 1, if none contain SO,
> flag is set to 0.
>
> Then it is easy to check if the flagged records meet your other
> conditions.
>
> Garry Gelade
> Business Analytic Ltd.

>
> David Wright-6 wrote:
>>
>> The data set contains student hold information including a hold code
>> (e.g., NF = no fee paid) and a start & end date., there are 20
>> possible
>> hold events for each student record.
>>
>> (data layout)
>> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
>> hold_start20, hold_edate20
>>
>> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
>> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
>> 01/13/2011, 11/1/2011
>> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>>
>> I need to select records (or create a binary denoting the event) in
>> which there is a 'SO' hold and the end date is equal to or greater
>> than
>> the system time.
>>
>> I suspect I need to perform a loop across the 20 possible sets
>> grabbing
>> the 'SO' if it exist & the end date, I could then create a new column
>> with each of these (hold & edate when SO occurs) & then select based
>> on
>> $time but not sure.  As always, any help would be greatly
>> appreciated.
>>
>> Thanks in advance.
>>
>> David
>>
>> =====================
>> 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
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4288759.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: select records across a set of variables which meet a condition

Bruce Weaver
Administrator
Hi David.  I was just trying to avoid listing all 20 of the variables like that.  What if you use SORT VARIABLES first?  Then you should be able to use v1 TO v20 rather than listing all of the variables.  Something like this, I think:

sort variables by name.
compute hold_flag=0.
do repeat
     holdc=hold_code1 TO hold_code20 /
     holde=hold_edate1 TO hold_edate20.
-  if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
end repeat.
select if hold_flag.

If this works, I like it better than my first suggestion.


David Wright-6 wrote
Bruce & Garry,

Thanks for your responses.  They got me thinking, with Garry's compute &
Bruce's hint at the Do Repeat, I could get around both the vector/loop &
casestovars by the following:


do repeat
     holdc=hold_code1 hold_code2 hold_code3  hold_code4 hold_code5
hold_code6 hold_code7 hold_code8 hold_code9 hold_code10
     hold_code11 hold_code12 hold_code13 hold_code14 hold_code15
hold_code16 hold_code17 hold_code18 hold_code19 hold_code20
     /holde=hold_edate1 hold_edate2 hold_edate3  hold_edate4 hold_edate5
hold_edate6 hold_edate7 hold_edate8 hold_edate9 hold_edate10
         hold_edate11 hold_edate12 hold_edate13 hold_edate14
hold_edate15 hold_edate16 hold_edate17 hold_edate18 hold_edate19
hold_edate20.
if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
end repeat.
select if (hold_flag=1).


Thanks again for all your assistance, without your suggestions I'd still
be stuck.

David




On Thu, Apr 7, 2011 at 9:55 AM, Bruce Weaver wrote:

> Hi David.  This can probably be done with VECTOR and LOOP, or
> DO-REPEAT.  But
> I wonder if it would not be much simpler to restructure the data (with
> VARSTOCASES) to have multiple rows per ID, with an Index variable to
> indicate the hold code number.  The variables would be:
>
> ID, Index, hold_code, hold_sdate, hold_edate
>
> On this restructured data set, flag cases where hold_code EQ 'SO' and
> hold_edate GT $time.
>
> compute SO_flag = (hold_code EQ 'SO') and (hold_edate GT $time).
>
> If you need to stick this flag variable back into the original wide
> file,
> use AGGREGATE to reduce to one row, keeping the MAX value of SO_flag
> for
> each ID, then merge that file (via MATCH FILES) with the original.
>
> HTH.
>

On Thu, Apr 7, 2011 at 11:10 AM, Garry Gelade wrote:

> Hi David
>
> The following will flag records containing SO.
>
> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>
> If one or more hold codes = SO, flag is set to 1, if none contain SO,
> flag is set to 0.
>
> Then it is easy to check if the flagged records meet your other
> conditions.
>
> Garry Gelade
> Business Analytic Ltd.

>
> David Wright-6 wrote:
>>
>> The data set contains student hold information including a hold code
>> (e.g., NF = no fee paid) and a start & end date., there are 20
>> possible
>> hold events for each student record.
>>
>> (data layout)
>> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
>> hold_start20, hold_edate20
>>
>> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
>> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
>> 01/13/2011, 11/1/2011
>> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>>
>> I need to select records (or create a binary denoting the event) in
>> which there is a 'SO' hold and the end date is equal to or greater
>> than
>> the system time.
>>
>> I suspect I need to perform a loop across the 20 possible sets
>> grabbing
>> the 'SO' if it exist & the end date, I could then create a new column
>> with each of these (hold & edate when SO occurs) & then select based
>> on
>> $time but not sure.  As always, any help would be greatly
>> appreciated.
>>
>> Thanks in advance.
>>
>> David
>>
>> =====================
>> 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
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4288759.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
--
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: select records across a set of variables which meet a condition

Bruce Weaver
Administrator
David, if you use VECTOR and LOOP instead of DO-REPEAT, you can exit the loop as soon as the flag is set rather than checking all 20 on every case.  See if this works:

sort variables by name.
compute hold_flag=0.
compute # = 0.
vector c = hold_code1 TO hold_code20 / e = hold_edate1 TO hold_edate20 .
loop.
-  compute # = # + 1.
-  if (c(#)='SO') and (e(#) ge xdate.date($time)) hold_flag=1.
end loop if hold_flag or (# EQ 20).



Bruce Weaver wrote
Hi David.  I was just trying to avoid listing all 20 of the variables like that.  What if you use SORT VARIABLES first?  Then you should be able to use v1 TO v20 rather than listing all of the variables.  Something like this, I think:

sort variables by name.
compute hold_flag=0.
do repeat
     holdc=hold_code1 TO hold_code20 /
     holde=hold_edate1 TO hold_edate20.
-  if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
end repeat.
select if hold_flag.

If this works, I like it better than my first suggestion.


David Wright-6 wrote
Bruce & Garry,

Thanks for your responses.  They got me thinking, with Garry's compute &
Bruce's hint at the Do Repeat, I could get around both the vector/loop &
casestovars by the following:


do repeat
     holdc=hold_code1 hold_code2 hold_code3  hold_code4 hold_code5
hold_code6 hold_code7 hold_code8 hold_code9 hold_code10
     hold_code11 hold_code12 hold_code13 hold_code14 hold_code15
hold_code16 hold_code17 hold_code18 hold_code19 hold_code20
     /holde=hold_edate1 hold_edate2 hold_edate3  hold_edate4 hold_edate5
hold_edate6 hold_edate7 hold_edate8 hold_edate9 hold_edate10
         hold_edate11 hold_edate12 hold_edate13 hold_edate14
hold_edate15 hold_edate16 hold_edate17 hold_edate18 hold_edate19
hold_edate20.
if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
end repeat.
select if (hold_flag=1).


Thanks again for all your assistance, without your suggestions I'd still
be stuck.

David




On Thu, Apr 7, 2011 at 9:55 AM, Bruce Weaver wrote:

> Hi David.  This can probably be done with VECTOR and LOOP, or
> DO-REPEAT.  But
> I wonder if it would not be much simpler to restructure the data (with
> VARSTOCASES) to have multiple rows per ID, with an Index variable to
> indicate the hold code number.  The variables would be:
>
> ID, Index, hold_code, hold_sdate, hold_edate
>
> On this restructured data set, flag cases where hold_code EQ 'SO' and
> hold_edate GT $time.
>
> compute SO_flag = (hold_code EQ 'SO') and (hold_edate GT $time).
>
> If you need to stick this flag variable back into the original wide
> file,
> use AGGREGATE to reduce to one row, keeping the MAX value of SO_flag
> for
> each ID, then merge that file (via MATCH FILES) with the original.
>
> HTH.
>

On Thu, Apr 7, 2011 at 11:10 AM, Garry Gelade wrote:

> Hi David
>
> The following will flag records containing SO.
>
> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>
> If one or more hold codes = SO, flag is set to 1, if none contain SO,
> flag is set to 0.
>
> Then it is easy to check if the flagged records meet your other
> conditions.
>
> Garry Gelade
> Business Analytic Ltd.

>
> David Wright-6 wrote:
>>
>> The data set contains student hold information including a hold code
>> (e.g., NF = no fee paid) and a start & end date., there are 20
>> possible
>> hold events for each student record.
>>
>> (data layout)
>> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
>> hold_start20, hold_edate20
>>
>> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
>> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
>> 01/13/2011, 11/1/2011
>> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>>
>> I need to select records (or create a binary denoting the event) in
>> which there is a 'SO' hold and the end date is equal to or greater
>> than
>> the system time.
>>
>> I suspect I need to perform a loop across the 20 possible sets
>> grabbing
>> the 'SO' if it exist & the end date, I could then create a new column
>> with each of these (hold & edate when SO occurs) & then select based
>> on
>> $time but not sure.  As always, any help would be greatly
>> appreciated.
>>
>> Thanks in advance.
>>
>> David
>>
>> =====================
>> 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
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4288759.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
--
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: select records across a set of variables which meet a condition

wsu_wright
In reply to this post by wsu_wright
Bruce,

Yes, this works too.   Tell me what the "..or (# EQ 20)."  does in the
end loop statement?


David




On Thu, Apr 7, 2011 at 2:31 PM, Bruce Weaver wrote:

> David, if you use VECTOR and LOOP instead of DO-REPEAT, you can exit
> the loop
> as soon as the flag is set rather than checking all 20 on every case.
> See
> if this works:
>
> sort variables by name.
> compute hold_flag=0.
> compute # = 0.
> vector c = hold_code1 TO hold_code20 / e = hold_edate1 TO hold_edate20
> .
> loop.
> -  compute # = # + 1.
> -  if (c(#)='SO') and (e(#) ge xdate.date($time)) hold_flag=1.
> end loop if hold_flag or (# EQ 20).
>
>
>
>
> Bruce Weaver wrote:
>>
>> Hi David.  I was just trying to avoid listing all 20 of the variables
>> like
>> that.  What if you use SORT VARIABLES first?  Then you should be able
>> to
>> use v1 TO v20 rather than listing all of the variables.  Something
>> like
>> this, I think:
>>
>> sort variables by name.
>> compute hold_flag=0.
>> do repeat
>>      holdc=hold_code1 TO hold_code20 /
>>      holde=hold_edate1 TO hold_edate20.
>> -  if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
>> end repeat.
>> select if hold_flag.
>>
>> If this works, I like it better than my first suggestion.
>>
>>
>>
>> David Wright-6 wrote:
>>>
>>> Bruce & Garry,
>>>
>>> Thanks for your responses.  They got me thinking, with Garry's
>>> compute &
>>> Bruce's hint at the Do Repeat, I could get around both the
>>> vector/loop &
>>> casestovars by the following:
>>>
>>>
>>> do repeat
>>>      holdc=hold_code1 hold_code2 hold_code3  hold_code4 hold_code5
>>> hold_code6 hold_code7 hold_code8 hold_code9 hold_code10
>>>      hold_code11 hold_code12 hold_code13 hold_code14 hold_code15
>>> hold_code16 hold_code17 hold_code18 hold_code19 hold_code20
>>>      /holde=hold_edate1 hold_edate2 hold_edate3  hold_edate4
>>> hold_edate5
>>> hold_edate6 hold_edate7 hold_edate8 hold_edate9 hold_edate10
>>>          hold_edate11 hold_edate12 hold_edate13 hold_edate14
>>> hold_edate15 hold_edate16 hold_edate17 hold_edate18 hold_edate19
>>> hold_edate20.
>>> if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
>>> end repeat.
>>> select if (hold_flag=1).
>>>
>>>
>>> Thanks again for all your assistance, without your suggestions I'd
>>> still
>>> be stuck.
>>>
>>> David
>>>
>>>
>>>
>>>
>>> On Thu, Apr 7, 2011 at 9:55 AM, Bruce Weaver wrote:
>>>
>>>> Hi David.  This can probably be done with VECTOR and LOOP, or
>>>> DO-REPEAT.  But
>>>> I wonder if it would not be much simpler to restructure the data
>>>> (with
>>>> VARSTOCASES) to have multiple rows per ID, with an Index variable
>>>> to
>>>> indicate the hold code number.  The variables would be:
>>>>
>>>> ID, Index, hold_code, hold_sdate, hold_edate
>>>>
>>>> On this restructured data set, flag cases where hold_code EQ 'SO'
>>>> and
>>>> hold_edate GT $time.
>>>>
>>>> compute SO_flag = (hold_code EQ 'SO') and (hold_edate GT $time).
>>>>
>>>> If you need to stick this flag variable back into the original wide
>>>> file,
>>>> use AGGREGATE to reduce to one row, keeping the MAX value of
>>>> SO_flag
>>>> for
>>>> each ID, then merge that file (via MATCH FILES) with the original.
>>>>
>>>> HTH.
>>>>
>>>
>>> On Thu, Apr 7, 2011 at 11:10 AM, Garry Gelade wrote:
>>>
>>>> Hi David
>>>>
>>>> The following will flag records containing SO.
>>>>
>>>> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>>>>
>>>> If one or more hold codes = SO, flag is set to 1, if none contain
>>>> SO,
>>>> flag is set to 0.
>>>>
>>>> Then it is easy to check if the flagged records meet your other
>>>> conditions.
>>>>
>>>> Garry Gelade
>>>> Business Analytic Ltd.
>>>
>>>>
>>>> David Wright-6 wrote:
>>>>>
>>>>> The data set contains student hold information including a hold
>>>>> code
>>>>> (e.g., NF = no fee paid) and a start & end date., there are 20
>>>>> possible
>>>>> hold events for each student record.
>>>>>
>>>>> (data layout)
>>>>> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
>>>>> hold_start20, hold_edate20
>>>>>
>>>>> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
>>>>> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
>>>>> 01/13/2011, 11/1/2011
>>>>> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>>>>>
>>>>> I need to select records (or create a binary denoting the event)
>>>>> in
>>>>> which there is a 'SO' hold and the end date is equal to or greater
>>>>> than
>>>>> the system time.
>>>>>
>>>>> I suspect I need to perform a loop across the 20 possible sets
>>>>> grabbing
>>>>> the 'SO' if it exist & the end date, I could then create a new
>>>>> column
>>>>> with each of these (hold & edate when SO occurs) & then select
>>>>> based
>>>>> on
>>>>> $time but not sure.  As always, any help would be greatly
>>>>> appreciated.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> David
>>>>>
>>>>> =====================
>>>>> 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
>>>>>
>>>>
>>>>
>>>> -----
>>>> --
>>>> Bruce Weaver
>>>> [hidden email]
>>>> http://sites.google.com/a/lakeheadu.ca/bweaver/
>>>>
>>>> "When all else fails, RTFM."
>>>>
>>>> NOTE: My Hotmail account is not monitored regularly.
>>>> To send me an e-mail, please use the address shown above.
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4288759.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
>>>
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4289258.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: select records across a set of variables which meet a condition

Bruce Weaver
Administrator
The # is a scratch variable that vanishes when the next execute occurs.  It is used as a counter, from 1 to a maximum of 20 in this example.  For cases/rows where none of the code variables equal 'SO', you want to exit the loop once the counter has reached 20.  Without that condition, it would keep on looping forever.

Cheers,
Bruce


David Wright-6 wrote
Bruce,

Yes, this works too.   Tell me what the "..or (# EQ 20)."  does in the
end loop statement?


David




On Thu, Apr 7, 2011 at 2:31 PM, Bruce Weaver wrote:

> David, if you use VECTOR and LOOP instead of DO-REPEAT, you can exit
> the loop
> as soon as the flag is set rather than checking all 20 on every case.
> See
> if this works:
>
> sort variables by name.
> compute hold_flag=0.
> compute # = 0.
> vector c = hold_code1 TO hold_code20 / e = hold_edate1 TO hold_edate20
> .
> loop.
> -  compute # = # + 1.
> -  if (c(#)='SO') and (e(#) ge xdate.date($time)) hold_flag=1.
> end loop if hold_flag or (# EQ 20).
>
>
>
>
> Bruce Weaver wrote:
>>
>> Hi David.  I was just trying to avoid listing all 20 of the variables
>> like
>> that.  What if you use SORT VARIABLES first?  Then you should be able
>> to
>> use v1 TO v20 rather than listing all of the variables.  Something
>> like
>> this, I think:
>>
>> sort variables by name.
>> compute hold_flag=0.
>> do repeat
>>      holdc=hold_code1 TO hold_code20 /
>>      holde=hold_edate1 TO hold_edate20.
>> -  if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
>> end repeat.
>> select if hold_flag.
>>
>> If this works, I like it better than my first suggestion.
>>
>>
>>
>> David Wright-6 wrote:
>>>
>>> Bruce & Garry,
>>>
>>> Thanks for your responses.  They got me thinking, with Garry's
>>> compute &
>>> Bruce's hint at the Do Repeat, I could get around both the
>>> vector/loop &
>>> casestovars by the following:
>>>
>>>
>>> do repeat
>>>      holdc=hold_code1 hold_code2 hold_code3  hold_code4 hold_code5
>>> hold_code6 hold_code7 hold_code8 hold_code9 hold_code10
>>>      hold_code11 hold_code12 hold_code13 hold_code14 hold_code15
>>> hold_code16 hold_code17 hold_code18 hold_code19 hold_code20
>>>      /holde=hold_edate1 hold_edate2 hold_edate3  hold_edate4
>>> hold_edate5
>>> hold_edate6 hold_edate7 hold_edate8 hold_edate9 hold_edate10
>>>          hold_edate11 hold_edate12 hold_edate13 hold_edate14
>>> hold_edate15 hold_edate16 hold_edate17 hold_edate18 hold_edate19
>>> hold_edate20.
>>> if (holdc='SO') and (holde ge xdate.date($time)) hold_flag=1.
>>> end repeat.
>>> select if (hold_flag=1).
>>>
>>>
>>> Thanks again for all your assistance, without your suggestions I'd
>>> still
>>> be stuck.
>>>
>>> David
>>>
>>>
>>>
>>>
>>> On Thu, Apr 7, 2011 at 9:55 AM, Bruce Weaver wrote:
>>>
>>>> Hi David.  This can probably be done with VECTOR and LOOP, or
>>>> DO-REPEAT.  But
>>>> I wonder if it would not be much simpler to restructure the data
>>>> (with
>>>> VARSTOCASES) to have multiple rows per ID, with an Index variable
>>>> to
>>>> indicate the hold code number.  The variables would be:
>>>>
>>>> ID, Index, hold_code, hold_sdate, hold_edate
>>>>
>>>> On this restructured data set, flag cases where hold_code EQ 'SO'
>>>> and
>>>> hold_edate GT $time.
>>>>
>>>> compute SO_flag = (hold_code EQ 'SO') and (hold_edate GT $time).
>>>>
>>>> If you need to stick this flag variable back into the original wide
>>>> file,
>>>> use AGGREGATE to reduce to one row, keeping the MAX value of
>>>> SO_flag
>>>> for
>>>> each ID, then merge that file (via MATCH FILES) with the original.
>>>>
>>>> HTH.
>>>>
>>>
>>> On Thu, Apr 7, 2011 at 11:10 AM, Garry Gelade wrote:
>>>
>>>> Hi David
>>>>
>>>> The following will flag records containing SO.
>>>>
>>>> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>>>>
>>>> If one or more hold codes = SO, flag is set to 1, if none contain
>>>> SO,
>>>> flag is set to 0.
>>>>
>>>> Then it is easy to check if the flagged records meet your other
>>>> conditions.
>>>>
>>>> Garry Gelade
>>>> Business Analytic Ltd.
>>>
>>>>
>>>> David Wright-6 wrote:
>>>>>
>>>>> The data set contains student hold information including a hold
>>>>> code
>>>>> (e.g., NF = no fee paid) and a start & end date., there are 20
>>>>> possible
>>>>> hold events for each student record.
>>>>>
>>>>> (data layout)
>>>>> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
>>>>> hold_start20, hold_edate20
>>>>>
>>>>> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
>>>>> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
>>>>> 01/13/2011, 11/1/2011
>>>>> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>>>>>
>>>>> I need to select records (or create a binary denoting the event)
>>>>> in
>>>>> which there is a 'SO' hold and the end date is equal to or greater
>>>>> than
>>>>> the system time.
>>>>>
>>>>> I suspect I need to perform a loop across the 20 possible sets
>>>>> grabbing
>>>>> the 'SO' if it exist & the end date, I could then create a new
>>>>> column
>>>>> with each of these (hold & edate when SO occurs) & then select
>>>>> based
>>>>> on
>>>>> $time but not sure.  As always, any help would be greatly
>>>>> appreciated.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> David
>>>>>
>>>>> =====================
>>>>> 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
>>>>>
>>>>
>>>>
>>>> -----
>>>> --
>>>> Bruce Weaver
>>>> [hidden email]
>>>> http://sites.google.com/a/lakeheadu.ca/bweaver/
>>>>
>>>> "When all else fails, RTFM."
>>>>
>>>> NOTE: My Hotmail account is not monitored regularly.
>>>> To send me an e-mail, please use the address shown above.
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4288759.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
>>>
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of-variables-which-meet-a-condition-tp4288196p4289258.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
--
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: select records across a set of variables which meet a condition

Garry Gelade
In reply to this post by Bruce Weaver
Hi Bruce.  Good point. I missed that! I like your long file method best
because although it needs more steps, each is simple and it is easy to see
what is going on - great for code maintenance.
Garry

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: 07 April 2011 18:26
To: [hidden email]
Subject: Re: select records across a set of variables which meet a condition

Hi Garry.  Your ANY method was the first thing that occurred to me too, and
that's what I would have suggested were it not for the additional need to
check on whether the end time for that particular hold is greater than or
equal to $TIME.  That second part seemed much easier to me with a LONG file
format, where there's only one end date per row.  Just out of curiosity, how
would you do it with the original WIDE file?

Cheers,
Bruce



Garry Gelade wrote:

>
> Hi David
>
> The following will flag records containing SO.
>
> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>
> If one or more hold codes = SO, flag is set to 1, if none contain SO, flag
> is set to 0.
>
> Then it is easy to check if the flagged records meet your other
> conditions.
>
> Garry Gelade
> Business Analytic Ltd.
>
*===========================================================================
======================

>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> David Wright
> Sent: 07 April 2011 11:41
> To: [hidden email]
> Subject: select records across a set of variables which meet a condition
>
> The data set contains student hold information including a hold code
> (e.g., NF = no fee paid) and a start & end date., there are 20 possible
> hold events for each student record.
>
> (data layout)
> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
> hold_start20, hold_edate20
>
> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
> 01/13/2011, 11/1/2011
> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>
> I need to select records (or create a binary denoting the event) in
> which there is a 'SO' hold and the end date is equal to or greater than
> the system time.
>
> I suspect I need to perform a loop across the 20 possible sets grabbing
> the 'SO' if it exist & the end date, I could then create a new column
> with each of these (hold & edate when SO occurs) & then select based on
> $time but not sure.  As always, any help would be greatly appreciated.
>
> Thanks in advance.
>
> David
>
> =====================
> 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
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of
-variables-which-meet-a-condition-tp4288196p4289020.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: select records across a set of variables which meet a condition

Bruce Weaver
Administrator
That's funny...I've come around to preferring the SORT VARIABLES + VECTOR-LOOP solution.   ;-)

Cheers,
Bruce


Garry Gelade wrote
Hi Bruce.  Good point. I missed that! I like your long file method best
because although it needs more steps, each is simple and it is easy to see
what is going on - great for code maintenance.
Garry

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: 07 April 2011 18:26
To: [hidden email]
Subject: Re: select records across a set of variables which meet a condition

Hi Garry.  Your ANY method was the first thing that occurred to me too, and
that's what I would have suggested were it not for the additional need to
check on whether the end time for that particular hold is greater than or
equal to $TIME.  That second part seemed much easier to me with a LONG file
format, where there's only one end date per row.  Just out of curiosity, how
would you do it with the original WIDE file?

Cheers,
Bruce



Garry Gelade wrote:
>
> Hi David
>
> The following will flag records containing SO.
>
> COMPUTE flag = any('SO', hold_code1, hold_code2, .... hold_code20).
>
> If one or more hold codes = SO, flag is set to 1, if none contain SO, flag
> is set to 0.
>
> Then it is easy to check if the flagged records meet your other
> conditions.
>
> Garry Gelade
> Business Analytic Ltd.
>
*===========================================================================
======================
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> David Wright
> Sent: 07 April 2011 11:41
> To: [hidden email]
> Subject: select records across a set of variables which meet a condition
>
> The data set contains student hold information including a hold code
> (e.g., NF = no fee paid) and a start & end date., there are 20 possible
> hold events for each student record.
>
> (data layout)
> ID, hold_code1, hold_sdate1, hold_edate1, ..... hold_code20,
> hold_start20, hold_edate20
>
> 12, SO, 04/01/2003, 12/01/2007, RA, 03/23/2007, 05/12/2008
> 23, TC, 05/08/2008, 12,31,2099, KP, 09/23/2010, 10,30,2010, SO,
> 01/13/2011, 11/1/2011
> 57, RA, 09/23/2010, 10,03,2010, SO, 11/01/2010, 12,31,2099
>
> I need to select records (or create a binary denoting the event) in
> which there is a 'SO' hold and the end date is equal to or greater than
> the system time.
>
> I suspect I need to perform a loop across the 20 possible sets grabbing
> the 'SO' if it exist & the end date, I could then create a new column
> with each of these (hold & edate when SO occurs) & then select based on
> $time but not sure.  As always, any help would be greatly appreciated.
>
> Thanks in advance.
>
> David
>
> =====================
> 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
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/select-records-across-a-set-of
-variables-which-meet-a-condition-tp4288196p4289020.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
--
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/).