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
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
>
>
>
>
>
>
|