0

I'm using template and sgrender in SAS to create heatmaps based on a different class variable. I'd like the output to update the title based off of the class variable each time to what the value of the class variable. So far, my code is like this (it prints a string title if I tell it to, but i can't get it to vary depending on the variable):

proc template;
  define statgraph heatmapparm;
    begingraph;
     entrytitle 'INSERT TITLE HERE';     *Update title here based on classVar;
      layout overlay;
         heatmapparm x=magX2 y=magZ2 colorresponse=percent / colormodel=(blue yellow red)
          name="heatmapparm" xbinaxis=false ybinaxis=false datatransparency=0;
        continuouslegend "heatmapparm" / location=outside valign=bottom;
      endlayout;
    endgraph;
  end;
run;

title #byval(classVar);
proc sgrender data=dataSet template=heatmapparm;
    by classVar;
run;

Thank you all!

1
  • 2
    Look at the dynamic variable portion of proc template in conjunction with entry title.
    – Reeza
    Dec 6, 2014 at 0:20

1 Answer 1

0

Use Macro variables to alter the titles. Here is an example

%let classVar=VARIABLEVALUE1; 

title &classVar.;
proc sgrender data=dataSet template=heatmapparm;
    by &classVar.;
run;

You can always write cleaner code by putting the proc sgrender code inside a SAS MACRO.

3
  • @Saliva I think I'm following what you're doing, but what do you mean by VARIABLEVALUE1? If you mean whatever the literal value is, in my case it is a string and I can't get it to work. Also, should I take away the entrytitle line of code in the proc template? Thanks!
    – Code4Days
    Dec 5, 2014 at 23:51
  • And the title is outputting in the SAS Results viewer with my previous code; however, I'm wanting it to be included in the ODS output (since that's what I will be referring to in the future). Thanks!
    – Code4Days
    Dec 5, 2014 at 23:54
  • VARIABLEVALUE1 is the assigned value to the macro variable I am creating in the statement. You can replace it. This is another example on how to modify the title: %LET STOCK=CVX; TITLE "Oil Barrel against %UPCASE(&STOCK.) Stock Price";
    – Salva
    Dec 6, 2014 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.