Date: Mon, 12 Mar 2012 09:55:35 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Removing STRINGS from A MACRO VARIABLE VALUE XXXX
In-Reply-To: <CAPRGo-=NfxZ2RNjpbSBWyd5bizwJ337eCvYVG0mWPPij26PEOg@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
If we're talking about variable names here is how I do it. The
advantages to fiddling with scan/transtrn and loops are obvious.
data have;
length DATE1 MTH YEAR ACTIVE date_open Data_closed MTH2 MTH3 $1;
stop;
call missing(of _all_);
run;
%LET VARS = DATE1 MTH YEAR ACTIVE DATE_OPEN DATA_CLOSED MTH2 MTH3;
%LET M = DATE_OPEN MTH2;
proc transpose data=have(obs=0) out=list1;
var &vars;
run;
proc transpose data=have(obs=0) out=list2;
var &m;
run;
proc sql noprint;
select _name_ into :VarsNo_M separated by ' '
from list1
where _name_ ne ALL(select _name_ from list2)
;
quit;
run;
%put NOTE: VarsNo_M=&varsno_m;
On 3/12/12, Dan Abner <dan.abner99@gmail.com> wrote:
> Hi everyone,
>
> I have the following code. I want to remove all variables listed in
> the &M macro variable (REGARDLESS OF ORDER) from the &VARS variable
> and save the results as &E. What I have works well except it requires
> that the variables be in the same order in &VARS and &M (which is
> definitely NOT the case). What is the easiest way to do this?
>
> %LET VARS = DATE1 MTH YEAR ACTIVE DATE_OPEN DATA_CLOSED MTH2 MTH 3;
> %LET M = DATE_OPEN MTH2;
>
> %LET E = %SYSFUNC(TRANWRD(&VARS,%STR(&M),%STR()));
>
>
> Thanks!
>
> Dan
>