LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 10 Jan 2008 10:15:25 -0800
Reply-To:   "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject:   Re: PROC SQL--select DISTINCT
Comments:   To: Tom White <tw2@MAIL.COM>
In-Reply-To:   A<20080110175444.BB3931F50B1@ws1-2.us4.outblaze.com>
Content-Type:   text/plain; charset="US-ASCII"

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


Back to: Top of message | Previous page | Main SAS-L page