Date: Wed, 11 May 2005 00:21:35 -0800
Reply-To: David Neal <afdbn@UAA.ALASKA.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David Neal <afdbn@UAA.ALASKA.EDU>
Subject: Re: counting
In-Reply-To: <1115799061.889269.44520@g14g2000cwa.googlegroups.com>
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Wow, it must be late, I didn't even think about the "nway" command.
RolandRB wrote:
> data plays;
> input @1 title $char27. year type $;
> cards;
> "A Midsummer Nights Dream" 1595 comedy
> "Comedy of Errors" 1590 comedy
> "Hamlet" 1600 tragedy
> "Macbeth" 1606 tragedy
> "Richard III" 1594 history
> "Romeo and Juliet" 1596 tragedy
> "Taming of the Shrews" 1593 comedy
> "Tempest" 1611 romance
> ;
> run;
>
> proc print data=plays;
> run;
>
> proc summary nway data=plays;
> class type;
> output out=playsum(drop=_type_ rename=(_freq_=count));
> run;
>
> proc print data=playsum;
> run;
>
>
>
>
> Obs title year type
>
> 1 "A Midsummer Nights Dream" 1595 comedy
> 2 "Comedy of Errors" 1590 comedy
> 3 "Hamlet" 1600 tragedy
> 4 "Macbeth" 1606 tragedy
> 5 "Richard III" 1594 history
> 6 "Romeo and Juliet" 1596 tragedy
> 7 "Taming of the Shrews" 1593 comedy
> 8 "Tempest" 1611 romance
>
>
> Obs type count
>
> 1 comedy 3
> 2 history 1
> 3 romance 1
> 4 tragedy 3
|