|
Mark:
SAS SQL and SQL in general has a GROUP BY clause that corresponds
closely to CLASS's in a SAS PROC MEANS with the NWAY option. It will
give you counts per group:
...
create table .... as
select customer,count(*) as count
from <SAS Dataset>
group by customer
;
....
But your description of what you are trying to achieve suggests that you
are looking for something simpler. If you have a distinct ID per
customer in a dataset that has one row per policy, the query
...
select count(distinct customerID) as count
from <SAS Dataset>
;
will give you a quick SQL solution.
Missing customer ID's or errors in customer ID's could lead to errors in
counts. Note that SQL handles missing values differently than PROC
MEANS.
Sig
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of Mark Wise
Sent: Thursday, January 05, 2006 10:14 AM
To: SAS-L@LISTSERV.UGA.EDU
Cc: Mark Wise
Subject: SQL Question
Hello,
I havent posted in a long time on this server, its so complicated to
post.
I have a quick question I want to write this if possible in SQL, how
would that be.
PROC MEANS DATA = dataset_name SUM N NWAY MISSING;
CLASS class1 class2 ;
VAR PREMIUM;
OUTPUT OUT=TEST0 SUM=;
RUN;
PROC MEANS DATA = TEST0 SUM N NWAY MISSING;
CLASS Class2;
VAR PREMIUM;
OUTPUT OUT=&DSNAME SUM=;
RUN;
The original dataset is at a policy level, and I want to count at the
customer level per class2 variable.
Any suggestions would be really appreicated. I am not really concerned
with the sum, I really need to know how many customers. I know how to
do this using proc means, but am curious how to do it in SQL.
Thanks,
MW
|