Date: Wed, 27 Oct 2010 16:51:27 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Concatenating a field for each ID
In-Reply-To: <BAY123-W48E6B0205A60452CF47645DE430@phx.gbl>
Content-Type: text/plain; charset=windows-1252
Why do you need to increment a counter that you don't use?
Do I = 1 By 1
On Wed, Oct 27, 2010 at 4:47 PM, toby dunn <tobydunn@hotmail.com> wrote:
> It is about as easy as this:
>
> Data Have ;
> Infile Cards ;
> Input ID Flag ;
> Cards ;
> 1 3
> 1 4
> 2 1
> 2 5
> 3 4
> ;
> Run ;
>
> Data Need ( Keep = ID Flag ) ;
> Length Flag $ 20 ;
>
> Do I = 1 By 1 Until( Last.ID ) ;
> Set Have ( Rename = ( Flag = _Flag ) ) ;
> By ID ;
> Flag = CatX( ',' , Flag , _Flag ) ;
> End ;
>
> Run ;
>
>
> Toby Dunn
>
>
> "I'm a hell bent 100% Texan til I die"
>
> "Don't touch my Willie, I don't know you that well"
>
>
>
>
>> Date: Wed, 27 Oct 2010 16:20:44 -0400
>> From: harrypotterdhf@EARTHLINK.NET
>> Subject: Concatenating a field for each ID
>> To: SAS-L@LISTSERV.UGA.EDU
>>
>> I have a dataset with id’s which might have more than 1 flag. I would like
>> to concatenate the flags for each id into new field. What is the best way to
>> accomplish this? Thanks!
>>
>> Input:
>>
>> id flag
>> -- ----
>> 1 3
>> 1 4
>> 2 1
>> 2 5
>> 3 4
>>
>> Desired output:
>>
>> id flag
>> -- ----
>> 1 3, 4
>> 2 1, 5
>> 3 4
>
|