Date: Mon, 12 Mar 2012 16:00:25 -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: <01384B2401936142AF5F65E3D12402780C2010D2@EX3VS1.nyced.org>
Content-Type: text/plain; charset=ISO-8859-1
If your computer uses ASCII characters, then the default delimiters
are as follows:
blank ! $ % & ( ) * + , - . / ; < ^ |
In ASCII environments that do not contain the ^ character, the SCAN
function uses the ~ character instead.
If your computer uses EBCDIC characters, then the default delimiters
are as follows:
blank ! $ % & ( ) * + , - . / ; < ¬ | ¢
On 3/12/12, Bolotin Yevgeniy <YBolotin@schools.nyc.gov> wrote:
> Note: countw does NOT count ".", so use with caution
>
> 59 data _z;
> 60 a = " a b c d e";
> 61 cwa = countw(a);
> 62 put a= cwa=;
> 63 b = " a b c d . e";
> 64 cwb = countw(b);
> 65 put b= cwb=;
> 66 run;
>
> a=a b c d e cwa=5
> b=a b c d . e cwb=5
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Bian, Haikuo
> Sent: Monday, March 12, 2012 12:42 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Removing STRINGS from A MACRO VARIABLE VALUE XXXX
>
> If just using Macro, based on the code structure you already have:
>
> %macro rem (vars=, m=);
> %let e=&vars;
> %do i=1 %to %sysfunc(countw(&m));
> %let e=%SYSFUNC(compbl(%sysfunc(TRANWRD(&e,%Scan(&M,&i),%str()))));
> %end;
> %put &e;
> %mend;
>
> %rem (vars=DATE1 MTH YEAR ACTIVE DATE_OPEN DATA_CLOSED MTH2 MTH 3,
> m=DATE_OPEN MTH2)
>
>
> Regards,
> Haikuo
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Dan
> Abner
> Sent: Monday, March 12, 2012 10:20 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Removing STRINGS from A MACRO VARIABLE VALUE XXXX
>
> 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
> -----------------------------------------
> Email messages cannot be guaranteed to be secure or error-free as
> transmitted information can be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The
> Centers for Medicare & Medicaid Services therefore does not accept
> liability for any error or omissions in the contents of this
> message, which arise as a result of email transmission.
>
> CONFIDENTIALITY NOTICE: This communication, including any
> attachments, may contain confidential information and is intended
> only for the individual or entity to which it is addressed. Any
> review, dissemination, or copying of this communication by anyone
> other than the intended recipient is strictly prohibited. If you
> are not the intended recipient, please contact the sender by reply
> email and delete and destroy all copies of the original message.
>
|