Macro for Proc template

Reply
Frequent Contributor
Posts: 110

Macro for Proc template

Hi Sas Experts,

 

am Creating a Macro for proc template style. Below is the error which am getting.

 

options mprint mautosource sasautos=(sasautos,'C:\RD\Macros');
 %Template(style)
WARNING: Apparent invocation of macro TEMPLATE not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

Below is my code

 

%let color1=cxF3F7FE;
%let color2=cx6497EB;

%macro Template(stylename);
%let color1=cxF3F7FE;
%let color2=cx6497EB;
proc template;
define style styles.&stylename;
parent=styles.default;
style twocolorramp / startcolor=&color1 endcolor=&color2;
class body / backgroundcolor=white;
class table / backgroundcolor=white;
class header, footer / backgroundcolor=white;
class data / backgroundcolor=white;
class systemtitle / backgroundcolor=white;
end;
run;
%mend;

 

 

Esteemed Advisor
Posts: 6,645

Re: Macro for Proc template


sanjay1 wrote:

 %Template(style)
WARNING: Apparent invocation of macro TEMPLATE not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

 


This simply means that at the time you called %template it was not in one of the sasautos paths and had not been declared in your program before.

Either make sure it is stored in the sasautos location or is defined/included in the program before you call it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 110

Re: Macro for Proc template

Hi,

Yes it is there in sasautos path. But still it is giving me error

 

Esteemed Advisor
Posts: 6,645

Re: Macro for Proc template

Show the code and log, from the %macro template() definition to the error.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Esteemed Advisor
Esteemed Advisor
Posts: 7,199

Re: Macro for Proc template

I am not sure why you would need a macro, templates themselves are meant to be generic.  So the parent= statement pulls all properties from parent template, and then you just alter the ones you want.  What benefit is there in then wrapping that in a macro?

Grand Advisor
Posts: 10,196

Re: Macro for Proc template

You may want to make an addition to your code:

 

style graphdata1 from graphdata1 / color=&color1;

style graphdata2 from graphdata2 / color=&color2;

 

If you apply the style to something with only two levels the color ramp will sometimes default to using the graphdata1 and graphdata2 colors.

 

Frequent Contributor
Posts: 110

Re: Macro for Proc template

Hi I ran the code as you suggested, but still it is not working. am getting the error

 

Grand Advisor
Posts: 10,196

Re: Macro for Proc template

When I run your code the macro compiles and runes without error.

 

You should post the log of the code you are running including the macro call with the Option mprint; turned on.

Grand Advisor
Posts: 10,196

Re: Macro for Proc template

When I run your code the macro compiles and runes without error.

 

You should post the log of the code you are running including the macro call with the Option mprint; turned on.

Frequent Contributor
Posts: 110

Re: Macro for Proc template

Hi 

Whenever am invoking this macro individually it is working fine, but am getting error when am invoking this macro in different program.

Thing is am storing this macro in a library---(C:\RD\MACROS);

options mprint mautosource sasautos=(sasautos,'C:\RD\Macros');

 

And I am invoking this macro by

 %Template(style)

 

below is the log:
WARNING: Apparent invocation of macro TEMPLATE not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

Esteemed Advisor
Posts: 6,645

Re: Macro for Proc template

What is the name of the file (in C:\RD\Macros) that contains your macro %template?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Esteemed Advisor
Posts: 6,645

Re: Macro for Proc template

And take a look if the MAUTOSOURCE system option is set.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 110

Re: Macro for Proc template

Hi ,

I got it actually I have not given %include statment.

Now it is working fine with this %include 

Ask a Question
Discussion stats
  • 12 replies
  • 494 views
  • 0 likes
  • 4 in conversation