user27008
user27008

Reputation: 610

Conditionally print a TITLE in SAS?

I am making a macro and want to display different titles for different variables that go through my macro.

I have been trying something like below:

%MYMACRO (VARIABLE);
%IF &VARIABLE='MYVARIABLE' %THEN TITLE1 'TITLE A';
    %ELSE TITLE1 'TITLE B';
/* MY MACRO STUFF */
%MEND MYMACRO;

This doesn't work. I am most likely not going about this in the proper manner either. I am wondering if there is an easy way to do this or if I need to do it manually each time I want to change my titles.

Upvotes: 1

Views: 539

Answers (1)

Jeff
Jeff

Reputation: 1807

If your macro variable doesn't resolve to a quoted string, you will need to fix your conditional. For example like this:

%IF "&VARIABLE"="MYVARIABLE" %THEN TITLE1 'TITLE A';

This should be true when you run this:

%mymacro(MYVARIABLE);

Or the conditional in our example should resolve to true if you run this:

%mymacro('MYVARIABLE');

Upvotes: 1

Related Questions