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 (March 1998, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 31 Mar 1998 19:12:09 EST
Reply-To:     Gregory J Toland <greg_toland@ABTASSOC.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Gregory J Toland <greg_toland@ABTASSOC.COM>
Subject:      FW: PROC SORT Question

Thanks to the following people for their solutions. All seem to be more efficient than what I was using.

Abelson, Robert Robin R. High Tremblay, Bernard Zack, Matthew M.

rsoong@janus.jnj.com girish.s.patel@ccmail.census.gov

One Solution: Greg,

Assuming that MONTH is a numeric variable, a PROC SQL solution should work well (this is untested):

proc sql; create table output as select distinct car, state, min(month) as month from input group by car, state; quit;

If your MONTH variable is not numeric, write an INFORMAT to read it into a numeric variable, say NMONTH.

HTH,

Bob Abelson Otsuka America Pharmaceuticals "A nuclear power plant is infinitely safer than eating, because 300 people choke to death on food every year." - Dixy Lee Ray

> -----Original Message----- > From: Gregory J Toland [SMTP:greg_toland@ABTASSOC.COM] > Sent: Tuesday, March 31, 1998 11:38 AM > To: SAS-L@UGA.CC.UGA.EDU > Subject: PROC SORT Question > > I am looking to see if anyone has a better way of solving this example: > > My input dataset contains three variables CAR STATE MONTH > > Input: > Ford Florida March > Ford Florida February > Ford Florida June > Chevy Virginia August > Chevy Virginia May > Chevy Virginia December > > I want my output dataset to contain the first Monthly occurrence > of a > CAR STATE combination. > > Output: > Ford Florida February > Chevy Virginia May > > To solve this I do the following: > > Proc Sort data = Input out = interim > by CAR STATE MONTH; > Run; > > Proc Sort data = interim out = output nodupkey; > by CAR STATE; > Run; > > Does anyone know of a better technique? My input dataset has > several > thousand records with about 100 variables. To sort the dataset twice > takes up a > lot of resources. I also perform this technique several times throughout > my > master program. Help!!!!! Thank you. > > Gregory J Toland > Abt Associates Inc. > Sr. Programmer Analyst > greg_toland@abtassoc.com > (301) 913-0694


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