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 (July 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 7 Jul 2006 16:54:13 -0400
Reply-To:     Joe Whitehurst <joewhitehurst@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Whitehurst <joewhitehurst@GMAIL.COM>
Subject:      Re: Macros written on a boring Friday
Comments: To: "William W. Viergever" <william@viergever.net>
In-Reply-To:  <7.0.1.0.2.20060707134813.038e70c0@viergever.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Wild Bill,

Yes I would. I like fat, fast balls right down the middle so I can blast them into the upper deck in center field!

Joe

On 7/7/06, William W. Viergever <william@viergever.net> wrote: > > At 10:35 AM 7/7/2006, Rickards, Clinton (GE Consumer Finance) wrote: > >toby, > > > >Excellent. We would all benefit if you were bored more often... > > > all? > > not joe > > > > > > > >thanks, > >Clint > > > >-----Original Message----- > >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of toby > >dunn > >Sent: Friday, July 07, 2006 11:56 AM > >To: SAS-L@LISTSERV.UGA.EDU > >Subject: Macros written on a boring Friday > > > > > >Check Sort Information on a Data Set: > > > >%Macro GetSortInfo( DataIn = , CheckSort= , TypeOfSort = , SortVars = ) ; > >%Local DSID RC SortType SVars Sorted ; > > > >%Let DSID = %SysFunc( Open( &DataIn ) ) ; > > > >%Let SortType = %SysFunc( AttrC( &DSID , SortLvl ) ) ; > >%Let SVars = %SysFunc( AttrC( &DSID , SortedBy) ) ; > > > > > >%Let Rc = %SysFunc( Close( &DSID ) ) ; > > > > > >%If ( %Length( &SortType ) > 0 ) %Then %Do ; > > %Let Sorted = YES ; > >%End ; > >%Else %Do ; > > %Let Sorted = NO ; > >%End ; > > > > > >%If ( %Upcase( &CheckSort ) = YES ) %Then %Do ; > > &Sorted > >%End ; > > > >%If ( %Upcase( &TypeOfSort ) = YES ) %Then %Do ; > > &SortType > >%End ; > > > >%If ( %Upcase( &SortVars ) = YES ) %Then %Do ; > > &SVars > >%End ; > > > >%Mend GetSortInfo ; > > > > > >/* Example Usage: */ > > > >Data One ; > >Do I = 1 To 10 ; > > output ; > >End ; > >Run ; > > > >Proc Sort > >Data = One > > out = Two ; > >by I ; > >Run ; > > > > > >%put %GetSortInfo( DataIn=Two , CheckSort=Yes ) ; > >%put %GetSortInfo( DataIn=Two , CheckSort=Yes , TypeOfSort=Yes ) ; > >%put %GetSortInfo( DataIn=Two , CheckSort=Yes , TypeOfSort=Yes , > >SortVars=Yes) ; > > > > > > > > > >Macro to sort a list of values in a Macro Variable: > > > > > >%Macro OrderMList( List = ) ; > >%Local NElem Element Z K Type NewList OrderedList ; > > > > > >%Let NElem = %Eval( %SysFunc( CountC( &List , %Str( ) ) ) + ( %Length( > &List > >) > 0 )); > > > >%Do Z = 1 %To &NElem ; > > > > %Let Element = %Scan( %Str(&List) , &Z , %Str( ) ) ; > > > > %If ( &Type Ne Char ) %Then %Do ; > > %Let Type = %DataTyp( &Element ) ; > > %End ; > > > > %Let MyVar&Z = &Element ; > > > > %Let NewList = &NewList MyVar&Z ; > > > >%End ; > > > > > >%Let NewList = %SysFunc( TranWrd( %Str(&NewList) , %Str( ) , %Str(,) ) ) > ; > > > > > >%If ( &Type = CHAR ) %Then %Do ; > > %SysCall SortC( &NewList ) ; > >%End ; > >%Else %Do ; > > %SysCall SortN( &NewList ) ; > >%End ; > > > > > >%Do K = 1 %to &NElem ; > > %Let OrderedList = &OrderedList &&&MyVar&K ; > >%End ; > > > >&OrderedList ; > >%Mend OrdermList ; > > > > > >/* Example Usage */ > > > >%Let MyList = 3 5 6 4 1 2 ; > >%Let MyList = %OrderMList( List = &MyList ) ; > > > >%put &MyList ; > > > > > > > >%Let MyList = B E C A D ; > >%Let MyList = %OrderMList( List = &MyList ) ; > > > >%put &MyList ; > > > >Toby Dunn > > > --------------------------------------------------- > William W. Viergever > Viergever & Associates > Health Data Analysis / Systems Design & Development > Sacramento, CA 95825 > william@viergever.net > (916) 483-8398 > --------------------------------------------------- >


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