Data visualization with SAS programming

PROC SGPLOT, customizing text using my own style element - impossible ?

Reply
Contributor
Posts: 43

PROC SGPLOT, customizing text using my own style element - impossible ?

Hi to all,

I'm having a problem...

Let's work with this table :
DATA test;
DO x=1 TO 20;
y+25X+250;
OUTPUT;
END;
RUN;

I'd like to build this graph using PROC SGPLOT :

PROC SGPLOT DATA=test;
INSET "text of my INSET part 1" "part 2" / position=topleft ;
SERIES x=x y=y;
RUN;

but I would like to customize the text of my INSET : I would like to have a bold text, 13pt, using this color: CX800080

The TEXTATTRS option should be used here but you can only associate this option to a style element. So, I'm creating a new style using PROC TEMPLATE this way:

PROC TEMPLATE;
DEFINE STYLE modif4;
PARENT = styles.listing;
CLASS insettext /
FONT = (", ",13pt,bold)
COLOR = CX800080;
END;
RUN;

(using STYLE instead of CLASS) won't solve my problem)
If I'm now running this program:

ODS LISTING STYLE=modif4;
PROC SGPLOT DATA=test;
INSET "text of my INSET part 1" "part 2" / POSITION=topleft TEXTATTRS=INSETTEXT ;
SERIES X=x Y=y;
RUN;

I'm having this message in my log:
WARNING: The style reference 'insettext' is invalid. The reference will be ignored.
WARNING: The style reference 'insettext' is invalid. The reference will be ignored.

In fact, I can only associate TEXTATTRS to an existing style element as GraphTitleText, GraphFootnoteText, GraphDataText, GraphLabelText, GraphValueText (this latter one is the default style used by TEXTATTRS).

Well, I can modify one of the existing text style elements but those style elements are used by one text element of the graph. I would like to be sure that only my inset text will be formatted the way I want.

modifying GraphValueText will modify the values on the axis
modifying GraphDataText will modify the point label if I'm using the DATALABEL option,
etc.

Is there a problem here or is there a solution ?

best regards

Sébastien
SAS Super FREQ
Posts: 925

Re: PROC SGPLOT, customizing text using my own style element - impossible ?

Hey Sébastien,

The missing font control int he procedures is being addressed. In the meantime, you can work around this issue by having SGPLOT generate GTL for you and modifying the GTL. Taking your example, add the TMPLOUT option to SGPLOT:

PROC SGPLOT DATA=test tmplout="temp.sas";
INSET "text of my INSET part 1" "part 2" / position=topleft ;
SERIES x=x y=y; RUN;

temp.sas will look like this:
proc template;
define statgraph sgplot;
begingraph;
layout overlay;
Layout Gridded / Border=false halign=left valign=top;
Layout Gridded;
Entry halign=left "text of my INSET part 1" / textattrs=GraphValueText;
Entry halign=left "part 2" / textattrs=GraphValueText;
endlayout;
endlayout;
SeriesPlot X=x Y=y / primary=true LegendLabel="y" NAME="SERIES";
endlayout;
endgraph;
end;

Modify the textattrs as you said in your post:

proc template;
define statgraph sgplot;
begingraph;
layout overlay;
Layout Gridded / Border=false halign=left valign=top;
Layout Gridded;
Entry halign=left "text of my INSET part 1" / textattrs=GraphValueText(weight=bold size=13pt color=CX800080);
Entry halign=left "part 2" / textattrs=GraphValueText(weight=bold size=13pt color=CX800080);
endlayout;
endlayout;
SeriesPlot X=x Y=y / primary=true LegendLabel="y" NAME="SERIES";
endlayout;
endgraph;
end;

Add this call to execute the template:

proc sgrender data=test template=sgplot; run;
Contributor
Posts: 43

Re: PROC SGPLOT, customizing text using my own style element - impossible ?

Hi Dan

Thanks for your answer (we already had a conversation together.. the French guy with his problem with BAND... as you can see I'm still working on the SG procedures!).

Well, I'm having the expected result with your method and things are clearer now: in fact, you can't use your own style element (with their own name) to customize your result.

thanks!

best regards

Sébastien
Ask a Question
Discussion stats
  • 2 replies
  • 768 views
  • 0 likes
  • 2 in conversation