Date: Fri, 26 Aug 2011 15:54:09 -0700
Reply-To: Mary Rosenbloom <mary.rosenbloom.sas@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mary Rosenbloom <mary.rosenbloom.sas@GMAIL.COM>
Subject: Re: CATX -- can you improve this code?
In-Reply-To: <BLU152-W532931016352C2421CF2E3DE130@phx.gbl>
Content-Type: text/plain; charset=windows-1252
Thanks Toby!
I am going to submit a "Tip of the Day" on sascommunity.org for catX. I
would love to have your review if you are interested. Thanks very much for
your help either way!
Cheers,
Mary R.
On Fri, Aug 26, 2011 at 3:28 PM, toby dunn <tobydunn@hotmail.com> wrote:
> Data _Null_ ;
> A = 1 ;
> B = 1 ;
> C = 1 ;
> List = CatX( ',' , IfC( A = 1 , 'NONE' , '' ) ,
> IfC( B = 1 , 'MEDS' , '' ) ,
> IfC( C = 1 , 'HOSP' , '' ) ) ;
> Put List= ;
> Run ;
>
> Toby Dunn
>
>
> If you get thrown from a horse, you have to get up and get back on, unless
> you landed on a cactus; then you have to roll around and scream in pain.
>
> “Any idiot can face a crisis—it’s day to day living that wears you out”
> ~ Anton Chekhov
>
>
> > Date: Fri, 26 Aug 2011 18:16:55 -0400
> > From: mary.rosenbloom.sas@GMAIL.COM
> > Subject: CATX -- can you improve this code?
> > To: SAS-L@LISTSERV.UGA.EDU
>
> >
> > Hi all,
> >
> > I have a group of 0/1 variables used to specify treatments given
> following
> > and event. I would like to build a comma-separated list of these
> > treatments. Here is the code that I currently use:
> >
> > data have2;
> > set have;
> >
> > format tempnone tempmeds temphosp $20. listtrt $200.;
> > ***create temp variables for building list;
> > if none=1 then tempnone='None';
> > if meds=1 then tempmeds='Meds';
> > if hosp=1 then temphosp='Hospitalized';
> >
> > ***build list of treatments;
> > listtrt=catx(', ', tempnone, tempmeds, temphosp);
> >
> > drop temp: ;
> > run;
> >
> > Is there any way to avoid creating the TEMP variables and somehow
> > incorporate that code into the CATX call?
> >
> > Thanks for your help!
> >
> > Cheers,
> > Mary R.
>
|