LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 7 Dec 2004 20:13:41 -0600
Reply-To:     "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Subject:      Re: HELP:: by group  processing?
Comments: To: Steve Jones <st_jones77@YAHOO.COM>
Content-Type: text/plain; charset="iso-8859-1"

Steve, There are so many questions i want to ask, chiefly why? But that wont solve your problem. As you don't say and I am not a mind reader I will provide the frame work for you solve your problem and let you fill in the business logic for all your different situation. data one (drop = __:);; set temp; by id; retain __w . __x . __yesno ' ' __lowhigh ' '; if first.id then cnt = 0; cnt + 1; if cnt = 2 then do; __w = w; __x = x; end; if yesno = 'yes' then __yesno = yesno ; if highlow = 'mid' then __lowhigh = lowhigh ; if last.id then do: id = __id; w = __w; x = __x; yesno = __yesno; highlow = __highlow; output; end; run; You will need to determine what you will do in the cases like: there is no value of 'mid' or 'yes', what to do when you have more than one of these values, and what observations you want w and x for. HTH Toby Dunn

________________________________

From: SAS(r) Discussion on behalf of Steve Jones Sent: Tue 12/7/2004 5:48 PM To: SAS-L@LISTSERV.UGA.EDU Subject: HELP:: by group processing?

Hello all,

I have a dataset (an example below) that has multiple observations per person/ID.

data temp; input id w x yesno $ lowhigh $; datalines; 1 1 2 yes low 1 2 3 yes mid 1 2 4 no high 2 6 7 no mid 2 8 7 yes low 2 4 8 no . 3 3 7 yes high 3 9 7 yes mid 3 8 8 . mid ; run;

My goal is to summarize the information by reducing the data to one observation per ID. To accomplish this, I want to keep specific values of some variables in the dataset. For example, for the variable yesno, I want to keep 'yes' even though 'no' appeared in some instances. Similarly, for variable lowhigh, I want to keep 'mid'.

In essence I want an output dataset that looks like:

id w x yesno lowhigh 1 2 3 yes mid 2 8 7 yes mid 3 9 7 yes mid

I appreciate any pointers.

Thanks,

SJ.

-- Posted via Mailgate.ORG Server - http://www.Mailgate.ORG


Back to: Top of message | Previous page | Main SAS-L page