Date: Wed, 12 Jan 2000 15:26:57 -0000
Reply-To: andy blissett <andy.blissett@royalmail.co.uk>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: andy blissett <andy.blisset@ROYALMAIL.CO.UK>
Organization: royal mail
Subject: Re: Antwort: Problems with data step.
make sure that you define the lenght of the new variable first.
other wise its length will be set to say 8 on the first statement and once
you try to append firther data to the end of the string there will be no
space for it. Also consider using a=trim(a)!!b;
rather than a=a!!b;
as the trailing spaces within 'a' will be counted.
Drop me a line if I can help further
Andy Blissett
Gehard Hellriegel wrote in message <41256864.0043B301.00@data.WestLB.de>...
>try (not tested):
>
>(i assume, trt1-trtn are numeric!)
>convert all numerics to characters, before doing things like
>TERAPIA=TERAPIA!!","!!TRT1
>TERAPIA=TERAPIA!!","!!PUT(TRT1,2.)
>
>
>
>
>
>
>Angelo Menna <a.menna@AUSL.MO.IT> on 12.01.2000 00:46:46
>
>Bitte antworten an Angelo Menna <a.menna@AUSL.MO.IT>
>
>An: SAS-L@LISTSERV.UGA.EDU
>Kopie: (Blindkopie: DeTeCSM HellriegelG/D/ExternalStaff/WLB)
>Thema: Problems with data step.
>
>
>
>Dear All,
>please consider the following data:
>
>PATIENTC TRT1 TRT2 TRT3 TRT4
>131130 1 2 5 90
>131698 90
>131718 2 3 90 90
>131762 2 4 90 90
>131768 2 4 90 90
>131771 90
>131804 90 90
>131806 2 3 4
>131923 1 90 90
>131975 2 90 90
>
>I'd like to have a new var (TERAPIA) to obtain distinct values of trt1-trt4
>separated by comma
>(e.g. for PATIENTC=131718 TERAPIA='2,3,90')
>
>I tried this code (but it does not work):
>
>data pluto ;
>length terapia temp1 $30 temp2 $2 ;
>set pippo ;
>
>array baudo trt1-trt4 ;
>
>do i=1 to 4;
> if i=1 then
> do;
> terapia=trt1 ;
> temp2=trt1 ;
> end;
> else
> do;
> if baudo(i) then
> do;
> if temp2^=baudo(i) then
> do;
> temp1=terapia||','||baudo(i) ;
> temp2=baudo(i) ;
> terapia=temp1;
> end;
> end;
> end;
>end;
>run;
>
>
>Any help is appreciated.
>TIA, Angelo.
>
>
>
>
>
> Mit freundlichen Gruessen
>
>
> DeTeCSM, Gerhard Hellriegel
>
> WestLB
> Abteilung: 001-80622
> Aderstr. 22
> D - 40217 Duesseldorf
> Tel.: +49211 826 6173
> Fax: +49211 826 5393
|