BookmarkSubscribeRSS Feed
IsabelleM
Fluorite | Level 6

 

 

 

My dataset contains vitamin D intake from 4 different sources (bron) for 7 different subpopulations (a,b,c,d,e,f,g).

Is it possible to create reference lines that do not cover the entire width of a graph but with a limited to the concerned category.

 

SGPlot2.png

 

proc format; 
value formsubpop  1="a"
                  2="b"
			      3="c"
			      4="d"
			      5="e"
			      6="f"
			      7="g";
			      run;

proc sort data=VitD_aggr;
by subpop ;
run;

proc sgplot data=VitD_aggr;
  vbox VitD_tot/category=subpop group=bron grouporder=descending boxwidth=0.9 NOOUTLIERS;
    YAXIS LABEL = 'Usual vitamin D intake (ug/day)' GRID VALUES = (0 TO 50 BY 10); 
  xaxis display=(nolabel) ;
  REFLINE 10 /label="AI=10 ug/day" lineattrs=(color=green);
  REFLINE 25 /label="UL=25 ug/day" lineattrs=(color=red);
  REFLINE 15 /label="AI=15 ug/day" lineattrs=(color=green);
  REFLINE 50 / label="UL=50 ug/day" lineattrs=(color=red);
  format subpop formsubpop. ;
  keylegend / location =outside position =bottom across=1;
  run;

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

How do you know if a refline applies to a certain category? If it is in the 95% confidence interval? If it is in the quartile range?

IsabelleM
Fluorite | Level 6

Thank you for your reply.

The reflines depend on the subpop (=subpopulations) I will probably have to define them by subpop?

 

refline 10 and 50 apply to subpop's a, b, c and d

refline 15 and 50 apply to subpop's e, f and g

 

 

ballardw
Super User

It sounds like you are asking for something that likely is in the annotate facility. That will allow you do specify drawing a line between two coordinates over/under other elements. You would construct an appropriate data set with the drawing instructions and reference in the procedure with the SGANNO= option to indicate the set to use. There are a number of macros available to help such as %sgline to create the instructions given some parameters such as coordinates and line properties.

 

Reeza
Super User

Instead of a reference line think of it is as a customized scatter plot, with the symbols being a straight line. 

Add in the values for your individual reference to your data set, if it's not already included.

Then you can use SCATTER to include customized reference line. 

 


@IsabelleM wrote:

 

 

 

My dataset contains vitamin D intake from 4 different sources (bron) for 7 different subpopulations (a,b,c,d,e,f,g).

Is it possible to create reference lines that do not cover the entire width of a graph but with a limited to the concerned category.

 

SGPlot2.png

 

proc format; 
value formsubpop  1="a"
                  2="b"
			      3="c"
			      4="d"
			      5="e"
			      6="f"
			      7="g";
			      run;

proc sort data=VitD_aggr;
by subpop ;
run;

proc sgplot data=VitD_aggr;
  vbox VitD_tot/category=subpop group=bron grouporder=descending boxwidth=0.9 NOOUTLIERS;
    YAXIS LABEL = 'Usual vitamin D intake (ug/day)' GRID VALUES = (0 TO 50 BY 10); 
  xaxis display=(nolabel) ;
  REFLINE 10 /label="AI=10 ug/day" lineattrs=(color=green);
  REFLINE 25 /label="UL=25 ug/day" lineattrs=(color=red);
  REFLINE 15 /label="AI=15 ug/day" lineattrs=(color=green);
  REFLINE 50 / label="UL=50 ug/day" lineattrs=(color=red);
  format subpop formsubpop. ;
  keylegend / location =outside position =bottom across=1;
  run;

 


 

IsabelleM
Fluorite | Level 6

I have tried this out with polylines and polycont and it worked.

 

Thank you for your help!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1049 views
  • 2 likes
  • 4 in conversation