BookmarkSubscribeRSS Feed
SusanParker
Calcite | Level 5
My statistician again...

She wants the y-axes to be independent so that the bars will be actually show something. She wants the axes like they are in the lab_values example that is actually in the clinical graphs handout and not the sample code that is out there for that example, because the sample code doesn't have the axis for alkaline phosphatase.

The version below has the y-axes the same.

Here's her code:

Data one;
input lab $ armcd mwtmean vari $ result;
cards;
BB 1 1.30 cyto 0.00000
BB 1 1.30 pru 0.00000
BB 1 1.30 flush 0.00000
BB 1 1.30 infusion 0.33333
BB 1 1.30 chills 0.50000
BB 1 1.30 fatigue 0.16667
BB 2 1.62 cyto 0.14286
BB 2 1.62 pru 0.28571
BB 2 1.62 flush 0.14286
BB 2 1.62 infusion 0.28571
BB 2 1.62 chills 0.28571
BB 2 1.62 fatigue 0.14286
BB 3 7.30 cyto 0.14286
BB 3 7.30 pru 0.42857
BB 3 7.30 flush 0.28571
BB 3 7.30 infusion 0.57143
BB 3 7.30 chills 0.28571
BB 3 7.30 fatigue 0.42857
BB 4 7.02 cyto 0.25000
BB 4 7.02 pru 0.50000
BB 4 7.02 flush 0.25000
BB 4 7.02 infusion 0.75000
BB 4 7.02 chills 0.87500
BB 4 7.02 fatigue 0.37500
BB 5 10.59 cyto 0.15385
BB 5 10.59 pru 0.38462
BB 5 10.59 flush 0.38462
BB 5 10.59 infusion 0.69231
BB 5 10.59 chills 0.69231
BB 5 10.59 fatigue 0.61538
BB 6 3.71 cyto 0.16667
BB 6 3.71 pru 0.50000
BB 6 3.71 flush 0.33333
BB 6 3.71 infusion 0.83333
BB 6 3.71 chills 0.83333
BB 6 3.71 fatigue 0.83333
BB 7 5.90 cyto 0.33333
BB 7 5.90 pru 0.16667
BB 7 5.90 flush 0.33333
BB 7 5.90 infusion 0.66667
BB 7 5.90 chills 0.66667
BB 7 5.90 fatigue 1.00000
;

proc print;
run;

ODS path (prepend) work.tempgrap;

proc template;
define statgraph aepanel/store=work.tempgrap;
begingraph/designwidth=10in designheight=4.5in;
layout gridded / rowgutter=0.5;
layout datapanel classvars=(vari) / columnaxisopts=(tickvalueattrs=(size=5))
columns=2 rows=3 headerlabeldisplay=value
rowaxisopts=(griddisplay=on
display=(ticks tickvalues) linearopts=(viewmax=1 tickvaluepriority=true
tickvaluesequence=(start=0 end=12 increment=1))
displaysecondary=(ticks tickvalues)
altdisplaysecondary=(ticks tickvalues)
altdisplay=(ticks tickvalues)) ;
layout prototype / cycleattrs=true;
seriesplot x=armcd y=mwtmean /yaxis=y2 display=(markers)
markerattrs=(size=9px weight=bold)
lineattrs=(thickness=2px) name="series1";
barchart x=armcd y=result/ primary=true skin=modern outlineattrs=(color=black) name="series2";
endlayout;
endlayout;
discretelegend "series1" "series2";
endlayout;
endgraph;
end;
run;

ods listing close;
ods rtf file='test.rtf';

proc sgrender data=one template=aepanel;
run;

ods listing;
ods rtf close;

run;
8 REPLIES 8
DanH_sas
SAS Super FREQ
The TICKVALUESEQUENCE in your template is what is keeping your bars compressed. If you remove that, you'l probably get the result you expect.

Thanks!
Dan
SusanParker
Calcite | Level 5
Actually, when I take out the tickvaluesequence, then I didn't get the series plot at all and no errors. I, then, commented out the viewmax and the series plot came back, but I still don't have independent axes. I think if I could get the axes to independent, then there wouldn't be a problem with the bars being compressed. They would be on the right hand axis and the series on the left.

Should we be trying something other than datapanel?

Again, what we want is what was in the handout version of lab_values or in the set of SGRENDER examples, the humidity-dewpoint part of the 3-part lattice example, the right and left axes with their own scales.

Thanks!
DanH_sas
SAS Super FREQ
Hey Susan,

Try the template below and see if this is what you want.

Thanks!
Dan

------------
[pre]
proc template;
define statgraph aepanel/store=work.tempgrap;
dynamic PANELNUM;
begingraph/designwidth=10in designheight=4.5in;
layout gridded / rowgutter=0.5;
layout datapanel classvars=(vari) / columnaxisopts=(tickvalueattrs=(size=5))
columns=1 rows=3 headerlabeldisplay=value panelnumber=PANELNUM
rowdatarange=union row2datarange=union columndatarange=unionall
rowaxisopts=(griddisplay=on display=(ticks tickvalues)
linearopts=(tickvaluepriority=true)
displaysecondary=(ticks tickvalues)
altdisplaysecondary=(ticks tickvalues)
altdisplay=(ticks tickvalues)) ;
layout prototype / cycleattrs=true;
barchart x=armcd y=result/ primary=true skin=modern
outlineattrs=(color=black) name="series2";
seriesplot x=armcd y=mwtmean /yaxis=y2 display=(markers)
markerattrs=(size=9px weight=bold)
lineattrs=(thickness=2px) name="series1";
endlayout;
endlayout;
discretelegend "series1" "series2";
endlayout;
endgraph;
end;
run;

ods listing close;
ods rtf file='test.rtf';

proc sgrender data=one template=aepanel;
dynamic panelnum=1;
run;

proc sgrender data=one template=aepanel;
dynamic panelnum=2;
run;

ods listing;
ods rtf close;
[/pre]
SusanParker
Calcite | Level 5
Hey Dan!

It gives me a warning at row2datarange saying its assuming that rowdatarange was misspelled. This is sort of why I figured datapanel may not be the way to go. I was going to start trying to look for another option that had the y and y2 axisopts available. Is row2 possibly available in 9.2M3, which isn't out for us yet?
DanH_sas
SAS Super FREQ
Yes, you are correct. I think I assumed you to have 9.2m3 when you were attempting to assign the series plot to the y2 axis. I now understand why my earlier statement about removing TICKVALUESEQUENCE didn't work for you either :-). Given that your series data range is very different from your bar data range, the best option for you may be to use a LAYOUT OVERLAY to define graph with secondary axes and run the template in PROC SGRENDER using "vari" as a BY-group on the procedure. Let me know if that is acceptable.

Thanks!
Dan
SusanParker
Calcite | Level 5
Thanks Dan!

I'll give that a go later today. M3 isn't available, right?
DanH_sas
SAS Super FREQ
From what I understand, It has just now become available. If you're interested, just check with your representative for details.

Thanks!
Dan
SusanParker
Calcite | Level 5
Just made my request. Perhaps I won't have to figure out a new way to do that datapanel after all.

Woo-hoo!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 8 replies
  • 1477 views
  • 0 likes
  • 2 in conversation