Date: Wed, 16 Feb 2000 08:25:40 -0500
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: SAS novice question
Content-Type: text/plain; charset=US-ASCII
Given the data structure in the example, there is no reasonably natural
way to do this in a SAS DATA step. That's because the DATA step
basically processes one observation at a time and because the variable
namespace is a simple vector (no qualifiers or associative references).
It's hard to suggest a strategy without knowing a little more about
the data and the objectives.
One possibility is to define two views and merge them:
data all;
input id method var1 var2 var10;
cards;
1 1 2 3 2
1 2 3 4 6
2 1 1 5 4
2 2 2 2 6
;
data m1 / view=m1;
set all;
keep id var1;
where method=1;
rename var1 = var11;
run;
data m2 / view=m2;
set all;
keep id var1;
where method=2;
rename var1 = var21;
run;
data diff;
merge m1 m2;
by id;
diff = var11 - var21;
run;
There are more compact ways to code this.
> Date: Tue, 15 Feb 2000 12:06:52 -0600
> From: H Jeremy Bockholt <jeremy-bockholt@UIOWA.EDU>
> Subject: SAS novice question
>
> In SAS, is there a way to directly access a value of a variable when
> there is more then one value?
>
> example record
> --------------------------------
> id method var1 var 2 ... var10
> 1 1 2 3 2
> 1 2 3 4 6
> 2 1 1 5 4
> 2 2 2 2 6
> -------------------------------
>
> I have a method variable with 2 levels{1,2}, so each of my var1-var10
> has 2 values for each id.
>
> I want to be able to refer directly to var1 at a specific method level.
> Let's say I want to calculate
>
> diff=var1[method==1] - var[method==2]
>
>
> Is there an easy way to do this?
>
>
> thanks in advance for any advice,
> jeremy
>
> --
> H Jeremy Bockholt
> MH-CRC Neuroimaging Lab Database Analyst
> 2-126f MEB UI College of Medicine Iowa City IA work_phone: 335-8209
> http://iowa-mhcrc.psychiatry.uiowa.edu/neuroimaging