Date: Tue, 8 Feb 2005 10:55:45 -0800
Reply-To: jfh@stanfordalumni.org
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject: Re: Proc Transpose
In-Reply-To: <200502081833.j18IX2ii029893@listserv.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii
My first question would be "Why do you want to do this?" In general,
you're better off leaving data in normalized form until the last
possible moment. PROC TABULATE and PROC REPORT have made reporting on
normalized data much easier than in the old days.
But if that's really what you want, you'll first have to decide how
long the list of codes might be. After that, you could use something
like:
===== untested code
data new (keep=desc codelist);
retain desc; /* Make it first variable. */
length codelist $1000.;
retain codelist;
set old (keep=desc code);
by desc;
if first.desc then
codelist = '';
codelist = trim(codelist) || ' ' || code;
if last.desc then
output;
run;
=====
In version 9, you could use the CATX function instead trimming and
concatenating.
--- Alice Loeffler <Alice.Loeffler@KHPC.COM> wrote:
> This is probably mickey mouse to most of you. But I am trying to
> transpose a file that looks something like this:
>
> 01400 ANESTHESIA SERVICE op
> 01922 ANESTHESIA SERVICE op
> 01953 ANESTHESIA SERVICE op
> 01999 ANESTHESIA SERVICE op
> L4350 ANKLE CONTROL ORTHO op
> 99170 ANOGENITAL EXAM op
> 95147 ANTIGEN THERAPY SERV op
> 95144 ANTIGEN-SNGL DOSE V op
> 97016 APPLICATION MODALITY enc
> 97018 APPLICATION MODALITY enc
> 29125 APPLICATION OF SHORT op
> 29075 APPLICATION; ELBOW T op
> 36620 ARTERIAL CATH/CANNUL op
>
> Into something like this:
> ANESTHESIA SERVICE 01400 01922 01953 01999
> ANKLE CONTROL ORTHO L4350
> ANOGENITAL EXAM 99170
> ANTIGEN THERAPY SERV 95147
> ANTIGEN-SNGL DOSE V 95144
> APPLICATION MODALITY 97016 97018
> APPLICATION OF SHORT 29125
> APPLICATION; ELBOW T 29075
> ARTERIAL CATH/CANNUL 36620
>
> A simple Proc transpose is not working for me
>
> proc transpose data=PEDSa
> out= PEDSb;
> run;
>
> Any suggestions?
>
> Thank you for any and all assistance.
> Ally
>
>