BookmarkSubscribeRSS Feed
OS2Rules
Obsidian | Level 7
Hi All:

I'm no great shakes with Macro vars and processing, so I hope someone here can help out.

I have this program:

[pre]

%let period=Daily;
%include source(DAILY_PROCESS);

%let period=Weekly;
%include source(WEEKLY_PROCESS);

%let period=Monthly;
%include source(MONTHLY_PROCESS);

%if %eval(day("&t_day"+1)) = 1 %then %do;

%let period=Quarterly;
%include source(QUARTERLY_PROCESS);

%let period=Yearly;
%include source(YEARLY_PROCESS);

%end;

[/pre]

But I get an error on the %if statement- I can't use it 'in open code'. (Value of &t_day is yesterday).

I'm sure you can see what it is that I am trying to do here. This is the entire program - there are no DATA steps until the process code is included.

Thanks in advance.
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
%IF and macro conditional logic can only be used in a SAS Macro definition -- also sometimes called a SAS Macro program. A SAS Macro definition is like this:
[pre]
%macro mymacpgm(parm1=, parm2=);
....some code including %IF, %DO, etc other code, datastep code, proc code, etc....
%mend mymacpgm;
[/pre]

Now, to invoke the macro definition, you must do:
[pre]
%mymacpgm(parm1=wombat, parm2=koala)
[/pre]

This is a very good introduction to the Macro Facility, which will take you through the basics and explain why you can't use %IF in open code:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

cynthia

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 983 views
  • 0 likes
  • 2 in conversation