DATA Step, Macro, Functions and more

Macro error log malfunction?

Reply
hz8
N/A
Posts: 1

Macro error log malfunction?

I have a macro loop that isn't processing in SAS, but error log simply spits back the code to me with no explanations. Program is run from the top so no chance of overwriting or missing data; interestingly enough, the same code worked earlier. Restarting SAS doesn't work either.

Any help? Is it something wrong with the code?

For reference:

%macro loop;
%do i = 2004 %to 2010;
%if &i=2010 %then %let t=8;
%else %let t=12;
%do j = 1 %to &t ;

data work.tda_&i&j;
set work.tda2;
where month(datepart(month_date))=&j and
month((OpenDate))>=&j and
year(datepart(month_date))=&i and
year((OpenDate))=&i and
EAS_Prod Contains 'JUMBO';
run;

proc means data=work.tda_&i&j n sum mean;
class Dimension Cterm ;
var CurBal ;
run;

%end;
%end;
%mend loop;
SAS Super FREQ
Posts: 8,866

Re: Macro error log malfunction?

Hi:
The %MACRO/%MEND will only DEFINE the macro program and put it into the WORK.SASMACR catalog. You must still INVOKE the macro program.

What errors do you see in the log (if any) when you INVOKE the macro program? How do you know that the macro loop isn't "processing"? Have you turned on the debugging options before you INVOKE the macro program:
[pre]
options mprint symbolgen mlogic;

%loop

options nomprint nosymbolgen nomlogic;
[/pre]



cynthia
PROC Star
Posts: 7,473

Re: Macro error log malfunction?

Like Cynthia said, you didn't show a statement where you are calling your macro (i.e., a statement like:
%loop
)

The only other thing I can immediately think of is that your data may not be the same as when you have run the code in the past. Specifically, I was surprised to see a variable called month_date, but used in a function that requires a datetime variable.

Your code appeared to run correctly on my computer.

Art
Super Contributor
Super Contributor
Posts: 3,174

Re: Macro error log malfunction?

Also, consider that the WHERE statement you have coded will also work directly with PROC MEANS, unless you have additional purpose for creating your DATA step file work.tda_&i&j.

At a minimum, if your input file is rather large, consider creating an INDEX or otherwise a VIEW to use with your program most efficiently.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 3 replies
  • 214 views
  • 0 likes
  • 4 in conversation