Help using Base SAS procedures

CALL EXECUTE for MACRO

Accepted Solution Solved
Reply
Contributor
Posts: 38
Accepted Solution

CALL EXECUTE for MACRO

%macro LOOP;
%do i=103 %to 103/*&runupto*/ ;
proc sql noprint;
select SYSTEM, FILENAME, TABLE_NAME, ATTRIBUTES, JOIN_TABLE, SECOND , AMOUNT, PROGRAM, LOOKUP
into Smiley FrustratedYS, :FILE , Smiley SurprisedUTTABLE, :FIELDS, :JOINTABLE, :JOINFIELD, :CADTOTAL, :CHECKER, :LOOK
from DATAVALIDATION where NUMBER=103;
QUIT;
%PUT &FIELDS;
data _NULL_;
if &CHECKER='PROGRAM_CHECK' THEN

CALL EXECUTE(%PROGRAM_CHECK(SYSTEMS=&SYS,FIRST=&FIELDS,SECOND=&JOINFIELD,BALANCE=&CADTOTAL,PARENTTABLE=&FILE,JOINTABLE=&JOINTABLE));
RUN;
/*proc append base=SOURCE data=TABLE2 FORCE;
RUN;*/
%END;

%mend;

ERROR OCCURED:Invalid macro name ;. It should be a valid SAS identifier no longer than 32 characters.
ERROR: A dummy macro will be compiled.


 

question: I have to run the macro( when the if condition is passed i have to run MACRO_CHECk)

can anyone tell me what is the error for it and what is the correct wat to write it

 

Thanks in advance

 


Accepted Solutions
Solution
‎10-15-2015 09:24 AM
Super User
Posts: 5,509

Re: CALL EXECUTE for MACRO

Posted in reply to siddharthpeesary

A couple of items for starters ...

 

Does the value of &CHECKER_PROGRAM really include single quotes?  

 

Trying to add CALL EXECUTE just complicates the program without adding any functionality.  You already have a macro running. Why not get rid of the DATA step entirely:

 

%if &CHECKER=PROGRAM_CHECK %THEN

%PROGRAM_CHECK(SYSTEMS=&SYS,FIRST=&FIELDS,SECOND=&JOINFIELD,BALANCE=&CADTOTAL,PARENTTABLE=&FILE,JOINTABLE=&JOINTABLE);

 

 

View solution in original post


All Replies
Solution
‎10-15-2015 09:24 AM
Super User
Posts: 5,509

Re: CALL EXECUTE for MACRO

Posted in reply to siddharthpeesary

A couple of items for starters ...

 

Does the value of &CHECKER_PROGRAM really include single quotes?  

 

Trying to add CALL EXECUTE just complicates the program without adding any functionality.  You already have a macro running. Why not get rid of the DATA step entirely:

 

%if &CHECKER=PROGRAM_CHECK %THEN

%PROGRAM_CHECK(SYSTEMS=&SYS,FIRST=&FIELDS,SECOND=&JOINFIELD,BALANCE=&CADTOTAL,PARENTTABLE=&FILE,JOINTABLE=&JOINTABLE);

 

 

Contributor
Posts: 38

Re: CALL EXECUTE for MACRO

Posted in reply to Astounding

Thank you so much you are a genius... actually in my table "PROGRAM_CHECK " is in character format so I thought  in if statement it should be in quotations(i.e %if &CHECKER= 'PROGRAM_CHECK' %THEN .....) but it executed when it is not in the Quotes ..

 If possible can you also tell me the reason ? 

 

Thanks again-Smiley Happy

 

Super User
Posts: 5,509

Re: CALL EXECUTE for MACRO

Posted in reply to siddharthpeesary

DATA steps use quotes to compare strings, but macro language does not.  Here is a test you can run to become more famliar with the rules:

 

%macro test;

%let name=siddarth;

%if &name=siddarth %then %put Match #1;

%if &name='siddarth' %then %put Match #2;

%if '&name'='siddarth' %then %put Match #3;

%if "&name"="siddarth" %then %put Match #4;

%mend test;

%test

 

Of course, you can always invent a few more tests and experiment to become more familiar with the outcomes.

 

In the context of a DATA step, you would have to resolve macro variables and then understand what the DATA step looks like.  Resolving macro variables might generate:

 

if PROGRAM_CHECK = "PROGRAM_CHECK" then ..

if "PROGRAM_CHECK" = "PROGRAM_CHECK" then ...

if '&PROGRAM_CHECK" = 'PROGRAM_CHECK" then ...

 

The rules about using quotes or not all depend on whether the proper DATA step syntax would be expecting to see quotes at that point.

Contributor
Posts: 38

Re: CALL EXECUTE for MACRO

Posted in reply to Astounding

Thank You I will try it -Smiley Happy

 

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 404 views
  • 1 like
  • 2 in conversation