LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (July 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 Jul 2007 17:34:37 -0400
Reply-To:     Paul Dorfman <sashole@BELLSOUTH.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <sashole@BELLSOUTH.NET>
Subject:      Re: A variable Sorting Problem

John,

Using data _null_'s approach with a twist ensuing that it will work even in the (unlikely) case when the number of the variables is so large that their concatenated names fail to fit in a macro variable.

data work.test ; retain f 1 a 'a' d 3 b 'bbbb' e 4 c 'ccc' ; run ;

proc sql noprint ; create view svars as select name into :svars separated by ' ' from dictionary.columns where upcase (libname) = upcase ('WORK') and upcase (memname) = upcase ('TEST') order name ; quit ;

data _null_ ; call execute ('data vtest / view = vtest ;') ; call execute (' retain ') ; do until (z) ; set svars end = z ; call execute (name) ; end ; call execute (' ;') ; call execute ('run ;') ; stop ; run ;

This will create a view VTEST; just reference it from this point on instead of TEST. If you still want a full new data set with the variables rearranged by name, erase the </ view = vtest> portion in the code above. Beware, though, that rewriting a very large data set will lose you some I/O.

Kind regards ------------ Paul Dorfman Jax, FL ------------

On Thu, 26 Jul 2007 16:00:12 -0400, John Edward <entry_mid_level_sas@YAHOO.COM> wrote:

>I have a following dataset ( VARIABLES ARE a,b,c,d,e,f ): > >C B E A D F >-- -- -- --- -- -- >2 3 5 8 1 0 >5 8 2 2 8 2 > >I have to rearage them as follows in that datset: > >A B C D E F >-- -- --- -- --- - >8 3 2 1 5 0 >2 8 5 8 2 2 > >Thanks a lot for helpng me and letting me me things that I could not find >in books.


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