DATA Step, Macro, Functions and more

Changing a title with a logical condition

Reply
New Contributor
Posts: 3

Changing a title with a logical condition

Dear  all, I was wondering whether it was possible to use a logical operator to change the title of a plot in a proc gplot?

PROC Star
Posts: 1,190

Re: Changing a title with a logical condition

what kind of logical operator?

New Contributor
Posts: 3

Re: Changing a title with a logical condition

For example:

 

if (condition=true) then title "something";

PROC Star
Posts: 1,434

Re: Changing a title with a logical condition

You should make a little example of the code you want to run.  (e.g. the SGPlot step with some sample data, the condition you want to evaluate, the title statement you want to generate).

 

Assuming you want to conditionally generate a title statement, that usually means using the macro language, e.g.

 

%macro ... ;

  %if &condition %then %do;
    title2 "My Title"; 
  %end;

%mend;

But there are other ways to dynamically generate titles, e.g. in GTL.

 

Super User
Posts: 13,084

Re: Changing a title with a logical condition


teli4a wrote:

For example:

 

if (condition=true) then title "something";


What sets the value of the condition? A manual entry (you for instance), the result of a procedure, a value in a data set?

Can you provide examples of the conditions you want to use. Some may be easier than others. Hint: special characters especially % & ( ) comma may require more coding.

And can you provide some examples of the condition and what you want the title(s) to be.

Super User
Super User
Posts: 9,227

Re: Changing a title with a logical condition

If you want the simplest answer, stop using a graphing system that is well out of date.  Read up on proc template and the Graph Template language.  You can pass in the tile as a parameter for instance.  There is a great blog here:

https://blogs.sas.com/content/graphicallyspeaking/

Which has all examples of all types of graphs with loads of code examples.

 

Ask a Question
Discussion stats
  • 5 replies
  • 78 views
  • 0 likes
  • 5 in conversation