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 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 15 Oct 2002 18:49:05 -0400
Reply-To:   Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:   Re: weird sort problem | programming challenge
Comments:   To: "evan.cooch@NOSPAMCORNELL.EDU" <evan.cooch@NOSPAMCORNELL.EDU>
Content-Type:   text/plain; charset="iso-8859-1"

Your array rotation problem has a fairly standard solution in a qualified off-set of an array index: data _null_; call symput('_nobs',nobs); stop; set xx nobs=nobs; run; %macro shift(_trace=ON); data xx (drop=i j); array aa(&_nobs.) _temporary_; do i=1 by 1 until(end); set xx end=end nobs=_nobs; aa((i ne _nobs)*i + 1)=a; end; do j=1 to _nobs; a=aa(j); output; end; stop; run; %if (&_trace.=ON) %then %do; proc print; run; %end; %mend shift; %shift %shift %shift %shift

One odd note: has anyone seen this Note?

NOTE: Line generated by the invoked macro "SHIFT". 1 data _null_; call symput('_nobs',nobs); stop; set xx nobs=nobs; run; ---- 546

NOTE 546-185: The variable nobs may be uninitialized.

Sig

-----Original Message----- From: evan.cooch@NOSPAMCORNELL.EDU [mailto:evan.cooch@NOSPAMCORNELL.EDU] Sent: Tuesday, October 15, 2002 5:01 PM To: SAS-L@LISTSERV.UGA.EDU Subject: weird sort problem | programming challenge

Must be late in the day, or the beer has run otu. One or the other ;-)

Suppose you have a data set, containing the following simple oridnal sequence of numbers:

1 2 3 4

What I'm try to do is sequentially generate what I'll call 'frame-shift' sorts of these numbers:

4 1 2 3

then

3 4 1 2

then

2 3 4 1

leading back to

1 2 3 4

Any ideas how to do this (without using SQL)? I'm stuck...

Thanks!


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