Data visualization with SAS programming

ReferenceLine within DataLattice

Reply
Occasional Contributor
Posts: 16

ReferenceLine within DataLattice

I have a ReferenceLine statement within a layout prototype that is within a layout DataLattice. The CurveLabel prints several times across the graph, once for every change in the ColumnVar variable value. Is there a way to get the CurveLabel to print only once, say for either the maximum or minimum value of ColumnVar?
SAS Super FREQ
Posts: 888

Re: ReferenceLine within DataLattice

If I'm understanding this scenario correctly, you should be able to duplicate the ColumnVar column, put missing values where you do not want values displayed, and point the ReferenceLine statement at column. Let me know if that works for you.

Thanks!
Dan
Occasional Contributor
Posts: 16

Re: ReferenceLine within DataLattice

Would your method work for a horizontal reference line? Here is a rough outline of my code;

layout gridded / rowgutter=5 border=false ;
layout datalattice columnvar=cohortc / ...
layout prototype / wallDisplay=(fill) ;
BarChart x=xlbl y=_Mean1_yvar_ / group=weekc ;
ScatterPlot X=xlbl Y=_Mean1_yvar_ / ;
ReferenceLine y=3.7 / clip=true curvelabel='XXX' ;
endlayout ;
endlayout ;
endlayout ;

If ReferenceLine takes either x= or y= as input (but not both) I am not clear how I can point it at and still get a horizontal reference line.
SAS Super FREQ
Posts: 888

Re: ReferenceLine within DataLattice

Reference lines can specified directly (as in your case) or by a column. The column-driven technique enables you to create different reference lines in each cell. You can use the same techinque to control your labels. First, add your reference value and one label to your data. Here is one way to do it:

[pre]
proc sort data=sashelp.class out=temp; by sex; run;

data withref;
set temp;
by sex;
if first.sex then do;
refval = 3.7;
if (_n_ = 1) then reflabel="mylabel";
else reflabel=.;
end;
else do;
refval=.;
reflabel=.;
end;
run;
[/pre]

Then, change your REFERENCELINE statement to point to those columns:

ReferenceLine y=refval / clip=true curvelabel=reflabel ;

Give that a try and let me know if you get the result you want;

Thanks!
Dan
Occasional Contributor
Posts: 16

Re: ReferenceLine within DataLattice

Thank you very much Dan. That solution was so easy I'm embarrassed that I even had to ask. I need to read the documentation more closely.
Ask a Question
Discussion stats
  • 4 replies
  • 181 views
  • 0 likes
  • 2 in conversation