BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DinoPut
Obsidian | Level 7

Hi

 

I have been working on generating a line plot with error bars. I have defined the graph styles in proc template. I have also used proc template followed by sgrender to generate my graph. The lines generated by using series plot in proc template have the colors that I have defined, but the error bars don't seem to take up the same color. I was hoping that someone could help me with it. Any help would be greatly appreciated. Below is the code that I have used along with the output produced:

 

Code:

 

PROC TEMPLATE;
define style mystyle;
parent=styles.rtf;



style GraphData1 from GraphData1 / contrastcolor=black linestyle=1 MarkerSymbol="circle" color=black ;
style GraphData2 from GraphData2 / contrastcolor=BLUE linestyle=2 MarkerSymbol="Triangle" color=BLUE;
style GraphData3 from GraphData3 / contrastcolor=ORANGE linestyle=3 MarkerSymbol="square" color=ORANGE;
style GraphData4 from GraphData4 / contrastcolor=green linestyle=4 MarkerSymbol="PLUS" color=green ;
style GraphData5 from GraphData5 / contrastcolor=MAGENTA linestyle=5 MarkerSymbol="CircleFilled" ;
;

 

style GraphError /LineThickness = 1px;

END;
run;


*******************************************************************************;

proc template;
define statgraph line;

begingraph / designwidth=12in designheight=8.5in ;
entrytitle ' ';
layout lattice /columndatarange=union rowweights=(0.40 0.60);
*--------------------------------------------------------------------*
| Line Plot
*--------------------------------------------------------------------*;
layout overlay / yaxisopts=(label='Drug Concentration (mg/L)' linearopts=(viewmin=0 viewmax=60 tickvaluelist=(&yvals))) 
xaxisopts=(linearopts=(viewmin=0 viewmax=250 tickvaluelist=(&xvals))
display=none label="");

scatterplot x=ndy y=mean/yerrorlower=lower yerrorupper=upper  ;

seriesplot x=ndy y=mean / group=treat name="treat" lineattrs=(thickness=2 pattern=1 /*color=red symbol=square*/);
blockplot x=ndy block=ndy/datatransparency=.8 extendblockonmissing=true;


endlayout;

*--------------------------------------------------------------------*
| Bottom Line Plot
*--------------------------------------------------------------------*;
layout overlay / yaxisopts=(label='FeNO Concentration (mg/L)' linearopts=(viewmin=-80 viewmax=160 tickvaluelist=(&yvals))) 
xaxisopts=(label="Nominal Time (Days)" offsetmin=0.01 offsetmax=0.01
linearopts=(viewmin=0 viewmax=250 tickvaluelist=(&xvals)));
scatterplot x=ndy y=mean33/yerrorlower=lower33 yerrorupper=upper33 ;

seriesplot x=ndy y=mean33 /group=treat name="treat" lineattrs=(thickness=2 pattern=1) ;
blockplot x=ndy block=ndy/datatransparency=.8 extendblockonmissing=true;

discretelegend 'treat' / location=outside halign=left valign=bottom
order=columnmajor border=false valueattrs=(size=10pt);

endlayout;

endlayout;
endgraph;
end;
run;

ods rtf file="C:/lineplot.rtf" style=smystyle nogfootnote nogtitle bodytitle toc_data headery=720 footery=720 style=mystyle;
ods pdf file="C:/lineplot.pdf" style=mystyle;

proc sgrender data=final template=line ;
run;

 

Output:

 

 

Capture.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
LeliaM
SAS Employee

If you add the option GROUP=TREAT to your SCATTERPLOT statements, the error bars will be the colors you are expecting. 

View solution in original post

2 REPLIES 2
LeliaM
SAS Employee

If you add the option GROUP=TREAT to your SCATTERPLOT statements, the error bars will be the colors you are expecting. 

DinoPut
Obsidian | Level 7

Thank you, LeliaMcConnell! I had figured that out. Appreciate your response!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1823 views
  • 1 like
  • 2 in conversation