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 (November 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 13 Nov 2006 15:32:03 -0800
Reply-To:     "Hill, Andrew" <hill.ad@GHC.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Hill, Andrew" <hill.ad@GHC.ORG>
Subject:      Re: Help, how can I combine specific cells together?
Comments: To: toby dunn <tobydunn@HOTMAIL.COM>
Content-Type: text/plain; charset="us-ascii"

Thanks Toby.

Much less crowded and more efficient than my suggestion.

Andrew

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby dunn Sent: Monday, November 13, 2006 3:24 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Help, how can I combine specific cells together?

Data Need ; Length $ 50 ; Set Have ; By ID Site Date ; Retain AllVAlues ;

AllValues = CatX( ' ; ' , AllValues , Value ) ;

If Last.Date Then Do ; Output ; Call Missing( AllValues ) ; End ;

Run ;

Toby Dunn

Quickly, bring me a beaker of wine, so that I may wet my mind and say something clever. Aristophanes

Wise people, even though all laws were abolished, would still lead the same life. Aristophanes

You should not decide until you have heard what both have to say. Aristophanes

From: "Hill, Andrew" <hill.ad@GHC.ORG> Reply-To: "Hill, Andrew" <hill.ad@GHC.ORG> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Help, how can I combine specific cells together? Date: Mon, 13 Nov 2006 15:11:56 -0800

I often use a lag to do something like this:

data test_docs; set doc_cnt; by fln; /* create 7 NEW LAG QUES */ ARRAY X(*) date2 - date8; date2 =LAG1(date); date3 =LAG2(date); date4 =LAG3(date);

date5 =LAG4(date); date6 =LAG5(date); date7 =LAG6(date); date8 =LAG7(date); /* reset COUNT when BY-group changes */ IF FIRST.fln THEN COUNT=1; /* Reset the appropriate number of elements for each lag queue. Once for LAG1, twice for LAG2, and three times for LAG3... This stops 'bleed-over' of previous BY-group into the current BY-group. */ DO i = COUNT TO DIM(x); X(i)=.; END; count + 1; ;

You can then create the last column using compress:

Compress(var1,...,varn);

Run;

Then selcet the last row that has that id:

data doc_right; set test_docs; by fln; if last.fln then output; run;

Others might have better solutions, but this one is transparent and it is easy to debug if it fails.

HTH.

Andrew

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Yun Bai Sent: Monday, November 13, 2006 2:49 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Help, how can I combine specific cells together?

Hi, All

I have a table looks like:

ID Site Date Value -------------------------- |001 | aa | aaa | a1 | -------------------------- |001 | aa | aaa | a2 | -------------------------- |001 | aa | aaa | a3 | -------------------------- |002 | bb | bbb | b1 | -------------------------- |002 | bb | bbb | b2 | -------------------------- |003 | cc | ccc | c1 | -------------------------- |004 | dd | ddd | d1 | -------------------------- |004 | dd | ddd | d2 | --------------------------

I want to generate a new table to combine the last column together for the same ID, site and date. Like this:

ID Site Date Value ---------------------------------- |001 | aa | aaa | a1; a2; a3 | ---------------------------------- |002 | bb | bbb | b1; b2 | ---------------------------------- |003 | cc | ccc | c1 | ---------------------------------- |004 | dd | ddd | d1; d2 | ----------------------------------

How can I that? Thank you very much!

_________________________________________________________________ Use your PC to make calls at very low rates https://voiceoam.pcs.v2s.live.com/partnerredirect.aspx


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