```Date: Tue, 31 Mar 1998 19:12:09 EST Reply-To: Gregory J Toland Sender: "SAS(r) Discussion" From: Gregory J Toland 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