Date: Wed, 12 Jan 2000 13:19:44 +0100
Reply-To: detecsm_hellriegelg@WESTLB.DE
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gehard Hellriegel <detecsm_hellriegelg@WESTLB.DE>
Subject: Antwort: Problems with data step.
Content-type: text/plain; charset=us-ascii
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