BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

%macro LOOP;
%do i=103 %to 103/*&runupto*/ ;
proc sql noprint;
select SYSTEM, FILENAME, TABLE_NAME, ATTRIBUTES, JOIN_TABLE, SECOND , AMOUNT, PROGRAM, LOOKUP
into :SYS, :FILE , :OUTTABLE, :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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

4 REPLIES 4
Astounding
PROC Star

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

 

 

siddharthpeesary
Calcite | Level 5

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

 

Astounding
PROC Star

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.

siddharthpeesary
Calcite | Level 5

Thank You I will try it -:)

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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