Date: Fri, 13 Apr 2007 11:07:33 -0500
Reply-To: "Huang, JS" <Huang.JS@PRINCIPAL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Huang, JS" <Huang.JS@PRINCIPAL.COM>
Subject: Re: A SIMPLE MACRO PROBLEM AS A CONTINUATION OF UNCLEANED DATASET
PROBLEM
In-Reply-To: A<200704131517.l3DAldkE005136@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
The following should work:
data Given;
length VariableUN $ 40;
infile "D:\sas\test.txt";
input Subject VariableUN &;
run;
proc print;
run;
%MACRO select (varib,varibx,Result,Given);
data &Result(drop=&varib);
set &Given;
if sum(index(upcase(&varib),"ONGO"),index(upcase(&varib),"O/G"))
then
&varibx= 'A';
else
&varibx= 'B';
run;
proc print data=&Result;
run;
%MEND select;
%select(VariableUN,VariableUNXX,Result,Given)
***** Output *****
The SAS System 10:25
Friday, April 13, 2007 9
Obs VariableUN
Subject
1 City Bus leaving -ONGO; 1
2 Cneter city, california 2
3 City center colosed-ONGO 3
4 Center city working- ONGO; 4
5 Uptown Bronx, New York; 5
6 Mall center Closed ONGO evryday 6
7 Bus Station-O/G; 7
8 Train Staion 8
9 Airport-ONGOING 9
The SAS System 10:25
Friday, April 13, 2007 10
Variable
Obs Subject UNXX
1 1 A
2 2 B
3 3 A
4 4 A
5 5 B
6 6 A
7 7 A
8 8 B
9 9 A
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Rathindronath
Sent: Friday, April 13, 2007 10:17 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: A SIMPLE MACRO PROBLEM AS A CONTINUATION OF UNCLEANED DATASET
PROBLEM
I am trying rap a program Mr. Gerhard Hellriegel has provided in MACRO
as
below:
if sum(index(upcase(variableun),"ONGO"),
index(upcase(variableun),"O/G")
) then variableunXX="A";
else variableunXX="B";
I put it in MACRO as below:
%MACRO select (varib =, varibx =);
%IF sum(index(upcase(&varib),"ONGO"),
index(upcase(&varib),"O/G")
) %THEN &varibx= 'A';
%ELSE &varibx= 'B';
%MEND select;
data dataset_given;
set supp.dataset_given (keep = subject variableun); run;
%select (varib = variableun, varibx = variableunXX) run;
But it not working. I am new in MACRO. Can someone will be kind enough
to show how to do it in a correct way. I was always afraid of MACRO. If
someone help me now it would give me a great courage to use MACRO in
future as much as possible and I will keep learning by practising.
Thanks.
-----Message Disclaimer-----
This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.
Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.
While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.