BookmarkSubscribeRSS Feed
SR_FR
Obsidian | Level 7
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
2 REPLIES 2
DanH_sas
SAS Super FREQ
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;
SR_FR
Obsidian | Level 7
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1781 views
  • 0 likes
  • 2 in conversation