select under multiple conditions

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

select under multiple conditions

Patricio Calderon-2
Hello,

I'm trying to select youngest age under the following condition:

family  block  lot  age
1        5      10   10
1        5      10   15
2        8      9    9
2        8      12   17
3        10     50   8

Given the above grid, I need to select the youngest age per family, block
and lot.  For example, age 10 for family 1 would be selected. Any ideas?

Thank you very much for your help,

Patricio

=====================
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 under multiple conditions

Maguin, Eugene
I think this is just a simple aggregate problem. Look up the Aggregate command documentation and evaluate whether that will work.

Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Patricio Calderon
Sent: Wednesday, October 17, 2012 11:05 AM
To: [hidden email]
Subject: select under multiple conditions

Hello,

I'm trying to select youngest age under the following condition:

family  block  lot  age
1        5      10   10
1        5      10   15
2        8      9    9
2        8      12   17
3        10     50   8

Given the above grid, I need to select the youngest age per family, block and lot.  For example, age 10 for family 1 would be selected. Any ideas?

Thank you very much for your help,

Patricio

=====================
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 under multiple conditions

Rick Oliver-3
In reply to this post by Patricio Calderon-2
Is this what you're looking for?

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=family block lot
  /age_min=MIN(age).
select if age_min=age.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)




From:        Patricio Calderon <[hidden email]>
To:        [hidden email],
Date:        10/17/2012 10:23 AM
Subject:        select under multiple conditions
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hello,

I'm trying to select youngest age under the following condition:

family  block  lot  age
1        5      10   10
1        5      10   15
2        8      9    9
2        8      12   17
3        10     50   8

Given the above grid, I need to select the youngest age per family, block
and lot.  For example, age 10 for family 1 would be selected. Any ideas?

Thank you very much for your help,

Patricio

=====================
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 under multiple conditions

Patricio Calderon-2
In reply to this post by Patricio Calderon-2
Thank you.

=====================
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 under multiple conditions

Bruce Weaver
Administrator
In reply to this post by Patricio Calderon-2
Look up RANK in the fine manual, and pay attention to "BY varlist".  E.g.,

data list  list / family  block  lot  age (4f5.0).
begin data
1        5      10   10
1        5      10   15
2        8      9    9
2        8      12   17
3        10     50   8
end data.
rank age by family block lot.
compute flagged = Rage EQ 1 /* Rage = rank for age */ .
formats Rage flagged (f2.0).
list.

OUTPUT:

family block   lot   age Rage flagged
 
     1     5    10    10   1      1
     1     5    10    15   2      0
     2     8     9     9   1      1
     2     8    12    17   1      1
     3    10    50     8   1      1

Number of cases read:  5    Number of cases listed:  5


Patricio Calderon-2 wrote
Hello,

I'm trying to select youngest age under the following condition:

family  block  lot  age
1        5      10   10
1        5      10   15
2        8      9    9
2        8      12   17
3        10     50   8

Given the above grid, I need to select the youngest age per family, block
and lot.  For example, age 10 for family 1 would be selected. Any ideas?

Thank you very much for your help,

Patricio

=====================
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 under multiple conditions

David Marso
Administrator
In reply to this post by Patricio Calderon-2
Depends upon what you want to do.
Assuming file is sorted you could use either
AGGREGATE ... MODE ADDVAR ...
or MATCH FILES .../FIRST.  
RANK ... /BY is another option .
I leave it to you to fill in the ...

Patricio Calderon-2 wrote
Hello,

I'm trying to select youngest age under the following condition:

family  block  lot  age
1        5      10   10
1        5      10   15
2        8      9    9
2        8      12   17
3        10     50   8

Given the above grid, I need to select the youngest age per family, block
and lot.  For example, age 10 for family 1 would be selected. Any ideas?

Thank you very much for your help,

Patricio

=====================
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: select under multiple conditions

Patricio Calderon-2
In reply to this post by Patricio Calderon-2
Thank you all for your suggestions.  I will try them to see how they
work.  In the meantime, I solved the problem by the following:

1. sorted asc by "family" and "age"
2. selected as: family NE LAG(family)

The result is selection of first row, and since age is sorted asc, then it
would select the youngest age.

Thanks to all for all your help.

Patricio

=====================
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