LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 17 Apr 2009 03:23:19 -0400
Reply-To:   Søren Lassen <s.lassen@POST.TELE.DK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Søren Lassen <s.lassen@POST.TELE.DK>
Subject:   Re: SQL equivalent of sort nodupkey but with MT 1 key variable
Comments:   To: Christine Arriola <cmarriola@HOTMAIL.COM>
Content-Type:   text/plain; charset=ISO-8859-1

Proc sort with the nodupkey option does the following: It sorts, but only outputs the first record in each BY group. What you get depends on the initial order of the data.

Such a concept is foreign to SQL, which does not know anything about the order of rows in the table.

The closest you can get is SELECT DISTINCT (synonym: SELECT UNIQUE), which corresponds to the NODUP (not NODUPKEY) option in proc sort.

So you can do a query like create table data2 as select distinct State,County,VarA,VarB from data1 where VarA is not null order by state,country;

but that would correspond to proc sort data=Data1(keep=State County VarA VarB ) out=Data2 nodup; where VarA ne .; by State County; run;

which is not quite your original query.

Regards, Søren

On Thu, 16 Apr 2009 14:48:52 +0000, Christine Arriola <cmarriola@HOTMAIL.COM> wrote:

>Hi everyone, > > > >Can anyone tell me how to translate the following sort procedure into proc SQL? > > > >proc sort data=Data1(keep=State County VarA VarB ) out=Data2 nodupkey; > >where VarA ne .; > >by State County; > > > >I've searched the archive, but I can't seem to find an example that undups on more than one variable. > > > >Thanks, Christine > > > > > > > > >_________________________________________________________________ >Windows Live?: Keep your life in sync. >http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009


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