Date: Sun, 16 Feb 2003 03:34:01 +0000
Reply-To: John Whittington <John.W@MEDISCIENCE.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: John Whittington <John.W@MEDISCIENCE.CO.UK>
Subject: Re: Re-ordering the positions of columns
In-Reply-To: <E18kEdm-0001F8-00@coumxnn02.netbenefit.co.uk>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 21:24 15/02/03 -0500, lpogoda wrote (in small part):
>Only the first time I tried it under version 8, it didn't work.
>.... it turned out that he was controlling the print order by
>rewriting the dataset according to the variable order parameter, and doing
>it in exactly the way you suggested at the top of this post, with a RETAIN
>statement followed by a macro variable.
>
>And when we pulled the macro apart and ran things step by step manually,
>we found that even though the macro variable was correctly valued, when
>the dataset was rewritten this way, the variable order didn't change. And
>so the listing that was produced showed variables in whatever order they
>happened to occur in the dataset rather than in the order requested.
I can but presume that something about the program was 'wrong' - perhaps
the most likely (the most common mistake) being that the RETAIN statement
was not put before the SET one - since it works fine for me. Try the
following:
data test ;
one = 1 ; two = 2 ; three = 3 ;
run ;
%let myorder = three two one ;
data tryit ;
retain &myorder ;
set test ;
run ;
proc print ;
run ;
On v8.1 and v8.2 (also 6.12) that results in the desired re-ordering, as
witness the output of proc print:
Obs three two one
1 3 2 1
Kind Regards,
John
----------------------------------------------------------------
Dr John Whittington, Voice: +44 (0) 1296 730225
Mediscience Services Fax: +44 (0) 1296 738893
Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk
Buckingham MK18 4EL, UK mediscience@compuserve.com
----------------------------------------------------------------