| Date: | Fri, 8 Jun 2007 15:01:22 +0000 |
| Reply-To: | toby dunn <tobydunn@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | toby dunn <tobydunn@HOTMAIL.COM> |
| Subject: | Re: crosstabs |
|
| In-Reply-To: | <571082.8317.qm@web55913.mail.re3.yahoo.com> |
| Content-Type: | text/plain; format=flowed |
|---|
The output you sent was all garbled up but from what I can groak out of it,
it would seem you may want to investigate Proc Tabulate.
Toby Dunn
If anything simply cannot go wrong, it will anyway. Murphys Law #2.
The buddy system is essential to your survival; it gives the enemy somebody
else to shoot at.
Murphys Law #
Tell a man there are 300 billion stars in the universe and he'll believe
you. Tell him a bench has wet paint on it and he'll have to touch to be
sure. Murphys Law #9
From: dave crimkey <d_crimkey@YAHOO.COM>
Reply-To: dave crimkey <d_crimkey@YAHOO.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: crosstabs
Date: Fri, 8 Jun 2007 07:53:09 -0700
Sure, here's the output after I calculate the percentages in Excel
category description COUNT PERCENT TOTAL
5 100.00% ATEST 3 60.00% xxxx 3 60.00% yyyy
1 20.00% BTEST 1 20.00% zzzz 1 20.00%
CTEST 1 20.00% bbbb 1 20.00% cccc 1 20.00%
Thanks,
dave
Jack Clark <JClark@chpdm.umbc.edu> wrote:
Dave,
Will you provide a sample of what the output should look like - with
percentages?
Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
dave crimkey
Sent: Friday, June 08, 2007 9:54 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: crosstabs
I've adjusted the code that was sent to me for the crosstabs and it
works really well! Thanks. Of course I'm trying to do something more
with it and I'm not a knowledgeable Proc Sql person.
Here's my code:
data two;
input id code category $ description $ ;
cards;
1 10 ATEST xxxx
1 12 ATEST yyyy
2 10 ATEST xxxx
3 15 BTEST zzzz
4 22 CTEST bbbb
4 23 CTEST cccc
5 10 ATEST xxxx
;
proc freq data=two noprint;
tables category*description/ out=twofreq;
run;
proc sql;
create table need (drop=ordval) as
(select category, description, count as count, percent, '2' as ordval
from twofreq)
union
(select category, ' ' as description, count(distinct id) as count,. as
percent,'1' as ordval
from two
group by category)
union
(select ' TOTAL' as category, ' ' as description, count(distinct id)
as count, . as percent,'0' as ordval
from two)
order by category, ordval, description
;
quit;
proc print data=need;
by category;
id category;
run;
This gives me an additional TOTAL number of id's without counting
duplicates. I'd like my percentages calculated off of that total and
I've tried numerous things in the sql proc but can't seem to get it.
I've been just pulling the output into Excel and calculcating the
percentages there but I'd like to be able to do it all in SAS. Is it
possible to do it all in the proc sql, or do I have to take the dataset
and do further manipulations outside of sql?
dave
---------------------------------
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight
and hotel bargains.
---------------------------------
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
_________________________________________________________________
Get a preview of Live Earth, the hottest event this summer - only on MSN
http://liveearth.msn.com?source=msntaglineliveearthhm
|