Data Logic #2

  • Follow


Dear All



i have this data

sub test
111  A
111  B
222  D
222  C
333  B
333  D


how do i create a variable newvar and the dataset
should look like .. Any pointers

sub test newvar
111  A    AB
111  B    AB
222  D    DC
222  C    DC
333  B    BD
333  D    BD

Thanks in advance
Al



0
Reply Al 12/1/2010 6:32:15 PM

Al,

Have you considered using a double DOW?  E.g.:

data have;
  input sub test $;
  cards;
111  A
111  B
222  D
222  C
333  B
333  D
;

data want;
  do until (last.sub);
    set have;
    by sub;
    if first.sub then newvar=3Dtest;
    else newvar =3D catt(newvar,test);
  end;
  do until (last.sub);
    set have;
    by sub;
    output;
  end;
run;

HTH,
Art
-------------
On Dec 1, 1:32=A0pm, Al <ali6...@gmail.com> wrote:
> Dear All
>
> i have this data
>
> sub test
> 111 =A0A
> 111 =A0B
> 222 =A0D
> 222 =A0C
> 333 =A0B
> 333 =A0D
>
> how do i create a variable newvar and the dataset
> should look like .. Any pointers
>
> sub test newvar
> 111 =A0A =A0 =A0AB
> 111 =A0B =A0 =A0AB
> 222 =A0D =A0 =A0DC
> 222 =A0C =A0 =A0DC
> 333 =A0B =A0 =A0BD
> 333 =A0D =A0 =A0BD
>
> Thanks in advance
> Al

0
Reply art297 12/1/2010 7:08:45 PM


1 Replies
191 Views

(page loaded in 0.053 seconds)


Reply: