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
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