I am trying to create one images that shows the ROC curves for four factors ( JIF16 JIF5 SNIP SJR). I wanted to change the appearance for journal submission -- largely changing the font (sans-serif), no gridlines, removing top and right borders (if possible, optional), and ensuring a good dpi (they request 1200 but I can't seem to get that high without the java engine error). The code below is what I'm working with (largely from here: http://support.sas.com/resources/papers/proceedings10/233-2010.pdf) . The final image will not be output and I get this error:
What am I doing wrong??
ods graphics on;
ods trace on;
ods select ROCOverlay ;
ods output
ROCOverlay=ROCOverlaydata ROC = myROCdata;
proc logistic data=subset plots=roc(id=prob);
model STROBE_act_none(event='0') = JIF16 JIF5 SNIP SJR /nofit;
roc '2016 Journal Impact Factor' JIF16;
roc '5 Year Journal Impact Factor' JIF5;
roc 'Source Normalized Impact per Paper' SNIP;
roc 'SCImage Journal Rank' SJR;
roccontrast reference('2016 Journal Impact Factor') / estimate e; run; ods trace off; ods graphics off;
ods path work.templat(update)
sashelp.tmplmst (read);
proc template ;
define style styles.MyROCoverStyle; parent = styles.Journal;
style GraphFonts /
'GraphValueFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphLabelFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphTitleFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'NodeDetailFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'NodeInputLabelFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'NodeLabelFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'NodeTitleFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphTitle1Font' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphDataFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphLabel2Font' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphUnicodeFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphAnnoFont' = ("<sans-serif>, <MTsans-serif>", 10pt)
'NodeLinkLabelFont' = ("<sans-serif>, <MTsans-serif>", 10pt);
style GraphDataDefault / linethickness = 3px;
style GraphAxisLines / linethickness = 1px;
style GraphWalls / lineThickness = 0px FrameBorder = off;
style graphdata1 / linestyle = 1 ContrastColor = red;
style graphdata2 / linestyle = 10 ContrastColor = black;
style graphdata3 / linestyle = 7 ContrastColor = blue;
style graphdata4 / linestyle = 6 ContrastColor = green;
define statgraph Graphics.ROCOverlay;
notes "STROBE Active Endorsement and Journal Impact Indices";
dynamic _TITLE ;
BeginGraph;
entrytitle _TITLE;
layout overlayequated /equatetype = square
yaxisopts = ( gridDisplay = off
label = "Sensitivity"
offsetmin = 0.05
offsetmax = 0.05)
xaxisopts = ( gridDisplay = off
label = "1 - Specificity"
offsetmin = 0.05
offsetmax = 0.05)
commonaxisopts = ( tickvaluelist =(0 .25 .5 .75 1)
viewmin = 0
viewmax = 1
);
lineparm x=0 y=0 slope=1 / extend = true
lineattrs =( color = grey thickness = 1px);
seriesplot y =_SENSIT_ x=_1MSPEC_ /
connectorder = xaxis
tip = (group y x)
group = _ROC_
index = _GROUP_
name = "Step"
primary = true
lineattrs = (thickness = 1px);
seriesplot y = _y_ x = _x_ / LINEATTRS = ( PATTERN = 4 thickness = 3px)
Connectorder = xaxis;
scatterplot y = y_cutoff x = x_cutoff/ datalabel = cutoff
markerattrs = (size = 10pt
symbol = circle weight = bold);
discretelegend "Step" / Title = "ROC Curve (Area)"
LOCATION = INSIDE
HALIGN = RIGHT
VALIGN = BOTTOM
PAD = (RIGHT = 2PX bottom = 2px)
ORDER = ROWMAJOR
ACROSS = 1
BORDER = FALSE
TITLEATTRS = (family = 'arial' size = 10pt weight =
BOLD)
VALUEATTRS = (family = 'arial' size = 8pt);
endlayout; EndGraph; end; run;
ods listing;
style = MyROCoverStyle
image_dpi = 1000
gpath = "/folders/myshortcuts/sf_myfolders/PhD/";
ods graphics on/ antialias=off reset
imagefmt= jpg
imagename = "MyROCoverlay"
border = off
height = 6.5in
width = 6.5in
SCALE = on;
proc sgrender data = subset template = Graphics.ROCOverlay; run;
One thing that jumps out at me is that the ";" after "listing" is incorrect. The options after listing are part of the statement. DId you get a syntax error?
ods listing;
style = MyROCoverStyle
image_dpi = 1000
gpath = "/folders/myshortcuts/sf_myfolders/PhD/";
Sorry, not sure how that ; got in there. There's no ; after listing in my code. I don't get any errors except for the final seriesplot "step" error.
Without seeing the data, it appears to me that your "subset" data does not contain all of the variables needed by the template. I would suggest doing a PROC CONTENTS on that data set and crosschecking the variable list against your template.
The subset dataset has the outcome STROBE_act_none variable and the 4 predictor variables JIF16, JIF5, SNIP, and SJR although there are some missing values so 50 observations are dropped (because of the nofit option). Is there somewhere in the template text where I am supposed to replace text with these variable names? It generates the output dataset with the calculated sensitivity/1- specificity required for the ROC curve. The code below runs by itself, no problem. It's just the formatting stuff that's the issue.
ods graphics on;
proc logistic data=subset plots=roc(id=prob);
model STROBE_act_none(event='0') = JIF16 JIF5 SNIP SJR /nofit;
roc '2016 Journal Impact Factor' JIF16;
roc '5 Year Journal Impact Factor' JIF5;
roc 'Source Normalized Impact per Paper' SNIP;
roc 'SCImage Journal Rank' SJR;
roccontrast reference('2016 Journal Impact Factor') / estimate e; run; ods graphics off;
I think your intent was to use either the ROCOverlayData or the myROCData data sets on the PROC SGRENDER call instead of "subset". The variables in the "subset" data set do not match the ones in the template. The ODS OUTPUT statement below captures the data used for the ROCOverlay and ROC output objects from PROC LOGISTIC. My guess is that you want to render those results in a graph template.
ods output
ROCOverlay=ROCOverlaydata ROC = myROCdata;
I'm working off the documentation in the main thread and I really don't understand what I should be changing. Sorry. I need to use the subset dataset only.
ods output
ROCOverlay=subset?? ROC = subset;
Change the names of the output datasets to what you had before, then run PROC CONTENTS on them to see which one has the variables you need, Use that data set on the PROC SGRENDER call. You probably shouldn't use "subset" on PROC SGRENDER because that was your input dataset that you had PROC LOGISTIC analyze. I think you're insterested in the plot data from PROC LOGISTIC, which the ODS OUTPUT statement is giving you.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.