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:         Wed, 9 Jan 2008 14:12:18 -0800
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Help with data manipulation. Thanks!!!
In-Reply-To:  <30f27f6b-a1dd-483b-bf3d-029655806fdc@d21g2000prf.googlegroups.com>
Content-Type: text/plain; charset=iso-8859-1

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of olivesecret@GMAIL.COM > Sent: Wednesday, January 09, 2008 1:58 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Help with data manipulation. Thanks!!! > > I have a dataset which include 3 variables: id, i, j. For each id, the > values for i and j may be 1~4. It is required that the combination of > these 3 variables to be unique, which means, for example, the > combination of id=2 i=3 j=1 can be on the dataset for only one time. > If the combination shows up for two or more times on the datset, I > need keep only the first obs this combination shows up and remove > other obs it shows up. > > To solve the problem, I sort the dataset according to id i j. Then I > only need to do iterations within each id. But I do not know how to do > it by SAS. Can any people help me do it? > > Thanks a lot!!! > > Olive > > You have received a solution from Toby Dunn using PROC SORT. If your dataset is already sorted you could use a data step

data want; set have; by id i j; if first.j; run;

Or you could use PROC SQL

proc sql; create table want as select distinct id, i, j from have order by id, i, j ; quit;

Hope this is helpful,

Dan

Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204


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