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 (November 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 13 Nov 2007 18:07:30 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Select variables help
Comments: To: cherub <cherub2life@yahoo.com>
In-Reply-To:  <305575.27991.qm@web33302.mail.mud.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

%macro GetVarsEndingWith( DataIn = , Suffix = ) ; %Local Dsid NumOfVars VarList VarName Close I ;

%Let Dsid = %Sysfunc( Open ( &DataIn , IS ) ) ;

%Let NumOfVars = %Sysfunc( Attrn( &Dsid , Nvars ) ) ;

%Do I = 1 %To &NumOfVars ; %Let VarName = %Sysfunc( VarName( &Dsid , &I ) ) ;

%If ( %Substr( %SysFunc( Reverse(&VarName) ) , 1 , %Length(&Suffix) ) = %SysFunc( Reverse(&Suffix) ) ) %Then %Do ; %Let VarList = &VarList &VarName ; %End ;

%End ;

%Let Close = %Sysfunc( Close( &dsid ) ) ;

&VarList

%Mend GetVarsEndingWith ;

/** Example Usage **/

Data One ; AXXX = 1 ; BXXX = 1 ; CXZX = 1 ; AZZX = 1 ; AXZZ = 1 ; CXXX = 1 ; Run ;

Proc Print Data = One ; Var %GetVarsEndingWith( DataIn = One , Suffix = XXX ) ; Run ;

Toby Dunn

Compromise is like telling a lie, it gets easier and easier. Each compromise you make, that becomes your standard.

Perfection doesnt exist, once you reach it, its not perfect anymore. It means something else.

> Date: Tue, 13 Nov 2007 09:47:30 -0800 > From: cherub2life@YAHOO.COM > Subject: Select variables help > To: SAS-L@LISTSERV.UGA.EDU > > I have data which has more than 500 attributes, and there are 100 attributes which are ending with _isi, I am only interested in attributew which are ending with _isi? > > I only know using 'keep=' to select variables. It will be very painful and time consuming to type attribute one by one, does anyone know any quick way to select variables? > > Thanks in advance. > > > --------------------------------- > Never miss a thing. Make Yahoo your homepage.

_________________________________________________________________ Peek-a-boo FREE Tricks & Treats for You! http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us


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