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 18:35:21 +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: PROC SQL--select DISTINCT
Comments:   To: Tom White <tw2@mail.com>
In-Reply-To:   <20080110182033.038D81BF28D@ws1-1.us4.outblaze.com>
Content-Type:   text/plain; charset="Windows-1252"

Tom ,

Well when you grab the distinct values you now loose any linking back to the other 2 variables, perhaps this will head you in the right direction:

Proc SQL ;

Create Table Distinct As Select Distinct Var1 , Var2 , Var3 From Have ;

Create Table Need As Select A.* , B.Var4 , B.Var5 From Distinct As A , Have As B ;

Quit ;

If you need distinct values for Var-Var3 seperately then:

Proc SQL ; Create Table Need As Select A.Var1 , B.Var2 , C.Var3 , D.Var4 , D.Var5 From ( Select Distinct Var1 From Have ) As A , ( Select Distinct Var2 From Have ) As B , ( Select Distinct Var3 From Have ) As C , ( Select Var4 , Var5 From Have ) As D ; Quit ;

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Thu, 10 Jan 2008 13:20:33 -0500 > From: tw2@MAIL.COM > Subject: Re: PROC SQL--select DISTINCT > To: SAS-L@LISTSERV.UGA.EDU > > Toby, > > What I am attempting to do is to select DISTINCT values for VAR1, VAR3, and VAR3 > but all values for VAR4 and VAR5. The data summation problem I am trying to solve maybe requires something like this. > > T > > ----- Original Message ----- > From: "toby dunn" > To: "Tom White" , sas-l@listserv.uga.edu > Subject: RE: PROC SQL--select DISTINCT > Date: Thu, 10 Jan 2008 18:12:22 +0000 > > > > Tom , > > Im not sure what you are trying to end up with. Your code and what > I gather from your write up is basically after distinct values of > soome variables but non distinct values of others. The structure > doesnt makes sense, in order to get the distinct values you will > have to eleminate some of the values from the non distinct values, > in order to get the non distinct values you have to make the > distinct values non distinct. > > > > > Toby Dunn > > "Don't bail. The best gold is at the bottom of barrels of crap." > Randy Pausch > > "Be prepared. Luck is where preparation meets opportunity." > Randy Pausch > > >> Date: Thu, 10 Jan 2008 12:54:44 -0500 >> From: tw2@MAIL.COM >> Subject: PROC SQL--select DISTINCT >> To: SAS-L@LISTSERV.UGA.EDU >> >> 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 > > _________________________________________________________________ > Make distant family not so distant with Windows Vista® + Windows Live™. > http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008 > > > -- > Are we headed for a recession? Read more on the Money Portal > Mail.com Money - http://www.mail.com/Money.aspx?cat=money

_________________________________________________________________ Get the power of Windows + Web with the new Windows Live. http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_012008


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