BookmarkSubscribeRSS Feed
Mohammad
Calcite | Level 5

Hi, folks. I am trying to run this code. The purpose is to use the variables of var list which are changing over time in another macro. 

%let DEAScorelist=x501 x502 x503;

%macro Do_Forme:
data _null_;
%do i=1 to %sysfunc(coutw(&DEAscorelist));
 %let DEA_score= %scan(&DEAscorelist,&i);
	length line $300;
		%do DTS = 2007 to 2014;
			UTS=DTS+&PT.-1;
			DHS=DTS+&PT.;
			UHS=DTS+&PT.+&PH.-1;
			SDTS=put(DTS,4.);
			SUTS=put(UTS,4.);
			SDHS=put(DHS,4.);
			SUHS=put(UHS,4.);
			DT=substr(SDTS,3,2);
			UT=substr(SUTS,3,2);
			DH=substr(SDHS,3,2);
			UH=substr(SUHS,3,2);
    	line = cats('%nrstr(%merge_scores_results(DTS=', DTS, ',UTS=', UTS, ',DHS=', DHS, ',UHS=', UHS, ',DT=', DT, ',UT=',UT, ',DH=' ,DH, ',UH=' ,UH, ',DEA_score=' ,DEA_score, '));');
    	call execute(line);
  		%end;
  %end;
	run;
%mend Do_Forme;



%Do_Forme;

 Would you please help.

 

Thanks

 

7 REPLIES 7
Reeza
Super User

What's the question?

Mohammad
Calcite | Level 5
Reeza. It doesn't work.
Mohammad
Calcite | Level 5

Thanks for your reply. Actually, I receive the following warning message:

WARNING: Apparent invocation of macro DO_FORME not resolved.

Kurt_Bremser
Super User

@Mohammad wrote:

Thanks for your reply. Actually, I receive the following warning message:

WARNING: Apparent invocation of macro DO_FORME not resolved.


If you get that, the compilation of the macro failed. Probably because of the TO instead of %TO.

Kurt_Bremser
Super User

I guess your mixing macro code with datastep code causes the issue.

Since (as it seems to me) all you want to do is call a macro repeatedly with call execute, the loops can be done with data step code alone.

 

BTW, "it does not work" is on par with "a bicycle was stolen in Beijing". Don't force us to make guesses.

 

 

Astounding
PROC Star

A %DO loop should use %TO.

 

ballardw
Super User

In addition to likely macro and datastep loop confusion you are referencing macro variables PT  and PH  with out any clue as to what they may look like. So a failure for your DO_Forme macro may fail because of values of those variables.

 

From what I see inside your macro there is no need for macro loop processsing.

 

You should run your macro with the system options MPRINT and SYMBOLGEN at least once. You may get some ideas of where the actual problem is as well as hints as to why you don't want the %do DTS to be a macro loop. Note that %do DTS creates a macro varaible. So all of your other references to DTS are a missing datastep variable. And any missing value + something will be missing.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1998 views
  • 1 like
  • 5 in conversation