selecting cases

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

selecting cases

Hassan Taweel
Dear SPSSers

I have a larg dataset that contains farms information (many variables) such
as milk production, milk protein content, milk fat, milk lactose and so on,
I would like to select the cases for maximum milk production within farms,
or alternatively, i'd like the programe to display the max milk production
for each farm and the values that occurs at the max milk production of all
the other variables. See example below:

farm   milk    protein    fat   lactose
1       29         3.5        3.8      4.2
1       35        2.8         3.3     4.5
1       29         3.5        3.8      4.2
1       32         3           3         4
1       28         3.8         4         4.7
2       38        3           4       4
2       36       2.9         3.3     4.5
2       32        3.5         3.3     4.5
2        29        2.8         3.3     4.2
2        35        2.8         3.3     4.3
2        35        3.4         3.3     4.7


I'd like the programe to tell me display

farm 1 , max milk 35, value of milk protein at max milk = 2.8, ans do on
Farm 2, max milk 38, value of milk prtein at max milk = 3

Your help is very appreciated

Hassan

_________________________________________________________________
Make free PC-to-PC calls with no loss of life!
http://www.communicationevolved.com/en-ie/
Reply | Threaded
Open this post in threaded view
|

Re: selecting cases

Daniel E WILLIAMS
This code will do the trick:

SORT CASES BY farm milk.
AGGREGATE
 /OUTFILE = *
 /BREAK = farm
 /maxmilk = last(milk)
 /maxmilk_protein = last(protein)
 /maxmilk_fat = last(fat)
 /maxmilk_lactose = last(lactose).



Dan Williams
Forecasting, Research and Analysis Office
Department of Human Services
State of Oregon, USA
503 947 5354

>>> "Hassan Taweel" <[hidden email]> 5/7/2007 9:01:16 AM >>>

Dear SPSSers

I have a larg dataset that contains farms information (many variables)
such
as milk production, milk protein content, milk fat, milk lactose and so
on,
I would like to select the cases for maximum milk production within
farms,
or alternatively, i'd like the programe to display the max milk
production
for each farm and the values that occurs at the max milk production of
all
the other variables. See example below:

farm   milk    protein    fat   lactose
1       29         3.5        3.8      4.2
1       35        2.8         3.3     4.5
1       29         3.5        3.8      4.2
1       32         3           3         4
1       28         3.8         4         4.7
2       38        3           4       4
2       36       2.9         3.3     4.5
2       32        3.5         3.3     4.5
2        29        2.8         3.3     4.2
2        35        2.8         3.3     4.3
2        35        3.4         3.3     4.7


I'd like the programe to tell me display

farm 1 , max milk 35, value of milk protein at max milk = 2.8, ans do
on
Farm 2, max milk 38, value of milk prtein at max milk = 3

Your help is very appreciated

Hassan

_________________________________________________________________
Make free PC-to-PC calls with no loss of life!
http://www.communicationevolved.com/en-ie/
Reply | Threaded
Open this post in threaded view
|

Re: selecting cases

Melissa Ives
In reply to this post by Hassan Taweel
Assuming there are no 'ties' for maximum milk production, you could
aggregate on farm keeping maxmilk=max(milk) value in the working
dataset.  Then calculate mmprotein (protein for maximum milk) as:

If (maxmilk=milk) mmprotein=protein.


Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hassan Taweel
Sent: Monday, May 07, 2007 11:01 AM
To: [hidden email]
Subject: [SPSSX-L] selecting cases

Dear SPSSers

I have a larg dataset that contains farms information (many variables)
such as milk production, milk protein content, milk fat, milk lactose
and so on, I would like to select the cases for maximum milk production
within farms, or alternatively, i'd like the programe to display the max
milk production for each farm and the values that occurs at the max milk
production of all the other variables. See example below:

farm   milk    protein    fat   lactose
1       29         3.5        3.8      4.2
1       35        2.8         3.3     4.5
1       29         3.5        3.8      4.2
1       32         3           3         4
1       28         3.8         4         4.7
2       38        3           4       4
2       36       2.9         3.3     4.5
2       32        3.5         3.3     4.5
2        29        2.8         3.3     4.2
2        35        2.8         3.3     4.3
2        35        3.4         3.3     4.7


I'd like the programe to tell me display

farm 1 , max milk 35, value of milk protein at max milk = 2.8, ans do on
Farm 2, max milk 38, value of milk prtein at max milk = 3

Your help is very appreciated

Hassan

_________________________________________________________________
Make free PC-to-PC calls with no loss of life!
http://www.communicationevolved.com/en-ie/


PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.