| Date: | Fri, 7 Sep 2007 19:33:11 -0500 |
| Reply-To: | Wensui Liu <liuwensui@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Wensui Liu <liuwensui@GMAIL.COM> |
| Subject: | Re: moving data to next record |
|
| In-Reply-To: | <BA3F4D45820B6B42ABDB10BB82D4ADDE198945FC@exchange-01.opubco.oklahoman.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
you can do so using hash.
data winslow;
id + 1;
input A ;
cards;
11
13
16
21
;
run;
data _null_;
if _n_ = 1 then do;
declare hash h (dataset: "winslow", hashexp: 4, ordered: 'a');
h.definekey ('id');
h.definedata ('id', 'A');
h.definedone();
declare hiter iter("h");
end;
do rc = iter.next() by 0 while (rc = 0);
set winslow(rename = (a = aa));
rc = iter.next();
B = A - AA;
if rc = 0 then do;
put ' Next A = ' A ' Current A =' AA ' Current B = ' B;
end;
end;
run;
On 9/7/07, Ryan McNeill <RMcNeill@oklahoman.com> wrote:
> I've got a variable value I want to assign to the next record. Is it
> possible to do that in SAS? For instance, I want the value of var2 to go
> to the next record and become var1
>
> For example:
>
> var1 var2
> 123 345
> 345 098
> 098 324
> 324 001
> 001 etc....
>
--
===============================
"I am dying with the help of too many
physicians." - Alexander the Great, on his deathbed
===============================
WenSui Liu
(http://spaces.msn.com/statcompute/blog)
===============================
|