|
Hi Tom,
Does this get you closer to what you want?
data sample;
do i=1 to 10;
do j = 1 to 5;
do k = 1 to 3;
do m = 1 to 5;
do n = 1 to 3;
output;
end;
end;
end;
end;
end;
run;
* DISTINCT - unique combinations of all variables ;
* i.e. would get rid of duplicate records which ;
* the sample above has no dups. ;
proc sql;
create table result as
select
distinct
*
from
sample
;
quit;
* DISTINCT - unique combinations of most variables ;
* i.e. unique for i-j-k across the m-n ;
proc sql;
create table result as
select
distinct
i,j,k
from
sample
;
quit;
* COUNTs across the distinct unique combinations ;
* i.e. use GROUP BY INSTEAD OF DISTINCT ;
proc sql;
create table result as
select
i,j,k,
count(*) as count
from
sample
group by
i,j,k
;
quit;
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investments
Russell Investments
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom
White
Sent: Thursday, January 10, 2008 9:55 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: PROC SQL--select DISTINCT
Hello SAS-L
I have a SAS data set with many fields (variables).
Suppose I would like to write sql code like
proc sq;
create table FOO2 as
select(distinct VAR1), distinct(VAR2), distinct(VAR3),
VAR4, VAR5
from FOO1
group by VAR1, VAR2, VAR3, VAR4, VAR5;
quit;
SAS does not recognize the distinct function. In other words,
I cannot write
.....
select(distinct VAR1), distinct(VAR2), distinct(VAR3),
.....
quit;
Is there any way to select multiple DISTINCT variables like I am
attempting to do above?
Thank you.
T
--
Are we headed for a recession? Read more on the Money Portal
Mail.com Money - http://www.mail.com/Money.aspx?cat=money
|