BookmarkSubscribeRSS Feed
hz8
Calcite | Level 5 hz8
Calcite | Level 5
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;
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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
art297
Opal | Level 21
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 952 views
  • 0 likes
  • 4 in conversation