Date: Mon, 1 Oct 2007 09:22:44 -0700
Reply-To: Oli <walaba@GOOGLEMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Oli <walaba@GOOGLEMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Data rearrangement
In-Reply-To: <1191252786.627360.197610@k79g2000hse.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
On Oct 1, 4:33 pm, gealnidk <adse...@famnissen.dk> wrote:
> If for some reason you wont use proc means or you want to do more
> complex transformations, you could use a simple data step to solve
> your problem ;-)
> Please refine the code yourself, this is just a simple and quick hack.
>
> data diag;
> input @1 Diag0 @9 Diag1 @17 Diag2 @25 date $9.;
> datalines;
> 1 0 0 05-Oct-98
> 0 1 0 05-Oct-98
> 1 0 0 06-Oct-98
> 0 1 0 06-Oct-98
> 0 1 0 06-Oct-98
> 1 0 0 06-Oct-98
> 1 0 0 06-Oct-98
> 0 1 0 06-Oct-98
> 1 0 0 10-Oct-98
> 0 1 0 11-Oct-98
> 1 0 0 12-Oct-98
> 0 1 0 12-Oct-98
> 0 0 1 13-Oct-98
> 1 0 1 13-Oct-98
> 0 0 0 13-Oct-98
> ;
> run;
>
> proc sort data=diag; by date; run;
>
> data outout(keep=date all_admissions sum_diag0-sum_diag2);
> set diag(keep=date diag0-diag2);
> by date;
> if first.date then
> do;
> all_admissions=0;
> sum_Diag0=0;
> sum_Diag1=0;
> sum_Diag2=0;
> end;
> all_admissions+1;
> sum_Diag0+Diag0;
> sum_Diag1+Diag1;
> sum_Diag2+Diag2;
> if last.date then
> output;
> run;
Dear All,
Thanks for respopnding to my request and all your suggestions. This
forum provides amazingly vast opportunity for beginners like me to
cram varoius means of doing same thing using different methods. Your
suggestion has solved my problem.
|