| Date: | Fri, 16 Jun 2006 09:09:37 -0400 |
| Reply-To: | Wensui Liu <liuwensui@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Wensui Liu <liuwensui@GMAIL.COM> |
| Subject: | Re: Percentage of subgroups |
|
| In-Reply-To: | <7367b4e20606160544h4507a252h8fc1c8c704a3e920@mail.gmail.com> |
| Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
Well, the good side of my way is that you won't include the funky year
you don't want. It is not surprise to have year "2049" in many
databases.
On 6/16/06, data _null_; <datanull@gmail.com> wrote:
> When does an elegant solution involve mixing up the data with the code?
>
> What are you going to do when you get more years?
>
> On 6/15/06, Wensui Liu <liuwensui@gmail.com> wrote:
> > Maarten,
> >
> > Here is a more elegent solution in SQL:
> >
> > proc sql;
> > create table
> > wensui as
> > select
> > company,
> > sum(case when year = 2002 and delay ~= . then 1 else 0 end)/
> > sum(case when year = 2002 then 1 else 0 end) as delay2002 format = percent8.2,
> > sum(case when year = 2003 and delay ~= . then 1 else 0 end)/
> > sum(case when year = 2003 then 1 else 0 end) as delay2003 format = percent8.2
> > from
> > test
> > group by
> > company;
> > quit;
> >
> > On 6/15/06, Havik, Maarten <Maarten.Havik@ordina.nl> wrote:
> > > Hi,
> > >
> > > Can someone please help me with a percentage question?
> > > I've tried a lot, and searched SAS-L but can't find the right posts..
> > > I have a dataset like this:
> > >
> > > data test;
> > > input flight company $ year delay;
> > > datalines;
> > > 1 A 2002 13
> > > 2 A 2002 .
> > > 3 A 2003 5
> > > 4 A 2003 12
> > > 5 A 2003 .
> > > 6 B 2002 17
> > > 7 B 2002 28
> > > 8 B 2003 32
> > > 9 B 2003 .
> > > 10 B 2003 .
> > > 11 B 2003 .
> > > ;
> > >
> > > A missing for delay indicates a flight was on time.
> > > What i need is a report containing the percentage of delayed flights for each subgroup company & year, like this:
> > >
> > > Year
> > > Company 2002 2003
> > > A 50% 66,66%
> > > B 100% 25%
> > >
> > > Any help is appreciated!
> > > Maarten
> > >
> > >
> >
> >
> > --
> > WenSui Liu
> > (http://spaces.msn.com/statcompute/blog)
> > Senior Decision Support Analyst
> > Health Policy and Clinical Effectiveness
> > Cincinnati Children Hospital Medical Center
> >
>
--
WenSui Liu
(http://spaces.msn.com/statcompute/blog)
Senior Decision Support Analyst
Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center
|