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 (October 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 6 Oct 2008 12:35:43 -0500
Reply-To:     "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject:      Re: how to select the first value from a repeated dataset
Comments: To: jn_mao@yahoo.com
In-Reply-To:  <781201.10460.qm@web32706.mail.mud.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1

You can use WHERE to subject to VAR1 eq 3 then use FIRST. to pick the first obs of the subset, for example.

data FirstVarEQ3; set have(where=(var1 eq 3)); by id var1; if first.var1; run; proc print; run;

On 10/6/08, jn mao <jn_mao@yahoo.com> wrote: > Hello SAS-Ls, > > I have a longitudinal data set. Now I want to only select the first value of 3 from var1, how do I write the SAS code? Some ids have repeated 3, but I only want to output the first 3 and other variable values. > > My original data: > id var1 var2 > 1 3 11 > 1 3 12 > 1 5 13 > 2 2 5 > 2 3 7 > 2 3 8 > 2 4 11 > 3 2 6 > 3 3 9 > > The data I want: > id var1 var2 > 1 3 11 > 2 3 7 > 3 3 9 > > Can someone help me out this? Thanks much. > > Jane > > > > > >


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