Re: Choosing highest value of a variable for each id

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

Re: Choosing highest value of a variable for each id

Jim Marks
Is your data long (3 records with FEV1 for each id)? Please provide sample data.

Jim Marks
Sr. Manager, Market Research
KFHP, MAS
2101 E Jefferson St
Rockville, MD. 20852

> On Nov 27, 2019, at 8:14 AM, Sigrid Vikjord <[hidden email]> wrote:
>
> Caution: This email came from outside Kaiser Permanente. Do not open attachments or click on links if you do not recognize the sender.
>
> ______________________________________________________________________
> Hi,
>
> I have two variables; FEV1 and id. The FEV1 variable is numeric (5.45, 3.28
> etc.) and contains three measurements per id. Does anyone have ideas for a
> syntax that creates a variable "FEV1_best" that contains the highest
> measurement of FEV1 for each id?
>
> I'm using SPSS 25.
>
>
>
>
>
> --
> Sent from: https://urldefense.com/v3/__http://spssx-discussion.1045642.n5.nabble.com/__;!7TrXCGkIugIq!-MOC0JRy3x3gaTQLXx3yj7KhOO4Z2LPhCUWgzrQ8OgKRBS8sdQphBlO_NUMHLOk$
>
> =====================
> 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
NOTICE TO RECIPIENT:  If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents.  If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them.  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: Choosing highest value of a variable for each id

Jon Peck
You can do this with AGGREGATE,


AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=id
  /FEV1_MAX=MAX(FEV1).

On Wed, Nov 27, 2019 at 6:14 AM Sigrid Vikjord <[hidden email]> wrote:
Hi,

I have two variables; FEV1 and id. The FEV1 variable is numeric (5.45, 3.28
etc.) and contains three measurements per id. Does anyone have ideas for a
syntax that creates a variable "FEV1_best" that contains the highest
measurement of FEV1 for each id?

I'm using SPSS 25.





--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: Choosing highest value of a variable for each id

Mario Giesel-2
In reply to this post by Jim Marks
Use command AGGREGATE, e.g.

AGGREGATE OUTFILE * MODE = ADDVARIABLES
/BREAK id
/Fev1_best = MAX(Fev1).



Mario Giesel
Munich, Germany


Am Mittwoch, 27. November 2019, 14:40:25 MEZ hat Jim Marks <[hidden email]> Folgendes geschrieben:


Is your data long (3 records with FEV1 for each id)? Please provide sample data.

Jim Marks
Sr. Manager, Market Research
KFHP, MAS
2101 E Jefferson St
Rockville, MD. 20852

> On Nov 27, 2019, at 8:14 AM, Sigrid Vikjord <[hidden email]> wrote:
>
> Caution: This email came from outside Kaiser Permanente. Do not open attachments or click on links if you do not recognize the sender.
>
> ______________________________________________________________________
> Hi,
>
> I have two variables; FEV1 and id. The FEV1 variable is numeric (5.45, 3.28
> etc.) and contains three measurements per id. Does anyone have ideas for a
> syntax that creates a variable "FEV1_best" that contains the highest
> measurement of FEV1 for each id?
>
> I'm using SPSS 25.
>
>
>
>
>
> --
> Sent from: https://urldefense.com/v3/__http://spssx-discussion.1045642.n5.nabble.com/__;!7TrXCGkIugIq!-MOC0JRy3x3gaTQLXx3yj7KhOO4Z2LPhCUWgzrQ8OgKRBS8sdQphBlO_NUMHLOk$
>
> =====================
> 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
NOTICE TO RECIPIENT:  If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents.  If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them.  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
===================== 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: Choosing highest value of a variable for each id

katepeter097
In reply to this post by Jim Marks
Your issue is sorted out?



--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Choosing highest value of a variable for each id

Rich Ulrich
In reply to this post by Jim Marks
The less trivial question is how to add a bunch of variables
to all records, picking those from the record where FEV1 is
the maximum.

For that, you  can presort on FEV1 using Descending order,
instead of the default Ascending.  Then use Aggregate
(Presorted) to pick up the FIRST( ) for each of the other vars.
And the AddVars option, to keep all the records.

--
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of Sigrid Vikjord <[hidden email]>
Sent: Wednesday, November 27, 2019 5:18 AM
To: [hidden email] <[hidden email]>
Subject: Choosing highest value of a variable for each id
 
Hi,

I have two variables; FEV1 and id. The FEV1 variable is numeric (5.45, 3.28
etc.) and contains three measurements per id. Does anyone have ideas for a
syntax that creates a variable "FEV1_best" that contains the highest
measurement of FEV1 for each id?

I'm using SPSS 25.





--
Sent from: http://spssx-discussion.1045642.n5.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: Choosing highest value of a variable for each id

Jon Peck
Why not just use MAX in AGGREGATE?

On Fri, Feb 14, 2020 at 11:21 AM Rich Ulrich <[hidden email]> wrote:
The less trivial question is how to add a bunch of variables
to all records, picking those from the record where FEV1 is
the maximum.

For that, you  can presort on FEV1 using Descending order,
instead of the default Ascending.  Then use Aggregate
(Presorted) to pick up the FIRST( ) for each of the other vars.
And the AddVars option, to keep all the records.

--
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of Sigrid Vikjord <[hidden email]>
Sent: Wednesday, November 27, 2019 5:18 AM
To: [hidden email] <[hidden email]>
Subject: Choosing highest value of a variable for each id
 
Hi,

I have two variables; FEV1 and id. The FEV1 variable is numeric (5.45, 3.28
etc.) and contains three measurements per id. Does anyone have ideas for a
syntax that creates a variable "FEV1_best" that contains the highest
measurement of FEV1 for each id?

I'm using SPSS 25.





--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: Choosing highest value of a variable for each id

Rich Ulrich
MAX in Aggregate will pick up the max for each of the
vars, separately.  Trivial, read the fine manual.  I was
describing the problem of picking up all variables from
that one particular record where FEV1 was max.

--
Rich Ulrich

From: Jon Peck <[hidden email]>
Sent: Friday, February 14, 2020 1:44 PM
To: Rich Ulrich <[hidden email]>
Cc: SPSS List <[hidden email]>
Subject: Re: [SPSSX-L] Choosing highest value of a variable for each id
 
Why not just use MAX in AGGREGATE?

On Fri, Feb 14, 2020 at 11:21 AM Rich Ulrich <[hidden email]> wrote:
The less trivial question is how to add a bunch of variables
to all records, picking those from the record where FEV1 is
the maximum.

For that, you  can presort on FEV1 using Descending order,
instead of the default Ascending.  Then use Aggregate
(Presorted) to pick up the FIRST( ) for each of the other vars.
And the AddVars option, to keep all the records.

--
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of Sigrid Vikjord <[hidden email]>
Sent: Wednesday, November 27, 2019 5:18 AM
To: [hidden email] <[hidden email]>
Subject: Choosing highest value of a variable for each id
 
Hi,

I have two variables; FEV1 and id. The FEV1 variable is numeric (5.45, 3.28
etc.) and contains three measurements per id. Does anyone have ideas for a
syntax that creates a variable "FEV1_best" that contains the highest
measurement of FEV1 for each id?

I'm using SPSS 25.





--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

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