Date: Thu, 28 Sep 2000 12:06:12 GMT
Reply-To: charles_s_patridge@MY-DEJA.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: charles_s_patridge@MY-DEJA.COM
Organization: Deja.com - Before you buy.
Subject: Re: How to reverse variables
Max,
I tried this code but I do not see the desired results. What am I
missing? Thanks. I just wanted to add Paul's solution to the others
you received so I could post them to my web site for future use.
data vset;
v1=1;v2=2;v3=3;v4=4;v5=5;
run;
%let n = 5;
data reverse;
set vset;
call poke(reverse(peekc(addr(v1),&n)),addr(v1),&n);
run;
Regards,
Charles Patridge
Email: Charles_S_Patridge@prodigy.net
In article <20000927232534.403B036EE@sitemail.everyone.net>,
maxzwingli@mail.nu wrote:
> Thanks to Wei Yen, Paul Dorfman, Harry Doogendyk, Richard Graham,
Peter Crawford for their instant help. As a summary, I asked how to
reverse a 1-byte character array with &N elements without using an
additional intermediate array to hold the elements in the reverse order.
The one-array solution adopted is to swap opposite elements and move
towards center as offered by Paul Dorfman. Actually Paul went further
and offered a zero-array (!) solution I would never even suspect could
exist
>
> data reverse;
> set vset;
> call poke(reverse(peekc(addr(v1),&n)),addr(v1),&n);
> run;
>
> Up until I saw this rather unusual code, I never thought that poke,
peek and addr could be of any practical use whatsoever.
>
> Thanks Max
>
> _____________________________________________________________
> Get Your Own .NU Web Address Now! ---> http://WWW.NUNAMES.NU
>
--
Charles Patridge - PDPC, Ltd.
172 Monce Road - Burlington, CT 06013 USA
Phone: 860-673-9278 or 860-675-9026
Email: Charles_S_Patridge@prodigy.net - Web: www.sasconsig.com
Sent via Deja.com http://www.deja.com/
Before you buy.
|