|Date: ||Mon, 17 Nov 2008 08:49:17 -0500|
|Reply-To: ||SAS_learner <proccontents@GMAIL.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||SAS_learner <proccontents@GMAIL.COM>|
|Subject: ||Re: Re-Ordering the Variables|
|Content-Type: ||text/plain; charset=ISO-8859-1|
Thank you so much for the help with the Macro, Yes I am looking for a macro
very similar to what you have suggested. You have mentioned some
disadvantes about using View rather sas dataset. I know you have already
explained enough but I still did not understand what you mean
1) the reordering is done on the fly each time the view is used
I did not understand what you mean ??
2) a view doesn't have knowledge of the number of obs
Is this good or bad for me ??
3) the change in name can mess up down stream programs
What exactly do you mean ??
What Exactly I am doing is that after deriving and mapping variables coming
from Oracle database to SDTM variables then I need to put them in a
particular order the way it is in the Document for that purpose I am using
RETAIN statement at very end of the program and trying to END the datastep.
Right now everything is fine but tomorrow if some body accidently does
something in that dataset for any of the variables in the RETAIN list, then
their values would be retained ( I am scared about the missing values
getting the Previous values)
So I am looking for something would get me order and still not prone to any
changes when some body accidently does something.
On 11/14/08, Ian Whitlock <firstname.lastname@example.org> wrote:
> Summary: View for reordering variables
> SAS_Learner wants to have macro for reordering variables. I would
> suggest a view.
> %macro order ( data = &syslast, out =, list= ) ;
> %let data = &data ; /* force evaluation of &data */
> %if %length(&out) = 0 %then %let out = &data._v ;
> data &out / view = &out ;
> retain &list ;
> set &data ;
> run ;
> %mend order ;
> %order ( data=sashelp.class, out=class_v,
> list=age height name sex weight )
> proc contents data = class_v ;
> run ;
> The advantage of the view is that it doesn't cost to store the
> copy of the data. The disadvantages are
> 1) the reordering is done on the fly each time the view is used
> 2) a view doesn't have knowledge of the number of obs
> 3) the change in name can mess up down stream programs
> If you think the disadvantages outweigh the advantages then just
> change the DATA statement.
> You might join those suggesting that the data set dictionary be
> given the ability to reorder variables. This should be a trivial
> task since the physical order was separated from the logical
> order with the introduction of version 6 about 18 years ago. The
> failure to make use of that separation might now be considered a
> twenty year old design bug in SAS data sets.
> Ian Whitlock