Date: Wed, 23 Jan 2008 14:44:30 -0500
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: A lot of variables,
find max and number of variable for each obs
In-Reply-To: <E324B0F8D8A9434FB8A0C6A8F17F5EBD@aktuare.local>
Content-Type: text/plain; charset="US-ASCII"
Stefan
There may be more elegant solutions but this works fairly well.
Data steph;
input id var1 - var10;
cards;
1 22 11 55 66 88 99 100 1 888 2
2 33 444 55 66 77 88 99 100 222 1
3 1 2 3 4 5 66 7 888 9 100
run;
Proc transpose out=steph (rename = (col1 = maxvalue _name_ = maxvar )) ;
by id;
var var: ;
run;
proc sort out=steph;
by id descending maxvalue;
run;
Data steph;
set steph;
by id;
if first.id;
run;
proc print;
run;
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
Stefan Pohl
<stefan.pohl@ISH.
DE> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
A lot of variables, find max and
number of variable for each obs
01/23/2008 02:17
PM
Please respond to
Stefan Pohl
<stefan.pohl@ISH.
DE>
Hi SAS-group,
I have a data set with the variables var1-var10000. var1-var1000 are the km
driven per day for 1.000 days.
id var1 var2 ... var234 ...var756... var 1000
1 1 2 2 4 2
2 2 4 5 1 4
...
For each id I want to know which var delivers the highest value, for
example
id maxvar maxvalue
1 756 4
2 234 5
...
How can I manage this?
Thank your for help.
Stef.
-----------------------------------------
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.