BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NP2212
Fluorite | Level 6

Hi,

I need help to add reference line for proc sgplot, i find median survival time to get reference in graph and i can add reference line on both axis too but how to restrict line to specific time point. for example, i want to add line only up to 0.5 on X axis then how i can restrict it? 

1 ACCEPTED SOLUTION

Accepted Solutions
7 REPLIES 7
ballardw
Super User

I am not sure I understand your question.

 

Are you looking to add a reference line in a plot option of one of the survival procedures like LIFETEST?

 

Or are you looking to add a line to your SGPLOT code?

 

If you have have SGPLOT code, please show it.

NP2212
Fluorite | Level 6

i am looking to add line in sgplot 

NP2212_0-1726679682172.png

 

ballardw
Super User

Please post code as text copied from the editor and then pasted into a text box opened with the </> icon above the message window. That way if minor corrections to code are needed we can do so. When you post pictures we would have to retype the entire thing and I for one am too lazy to retype much.

 

If you want to provide a line that connects the points (x,0) to (x, 0.5) , that is not a refline which uses all Y values for a given x or all X values for a given y.

 

If I understand what  you want the easiest may be to add an observation value to your existing data set with the x, y values for the start and end and maybe use a DROPLINE. You can provide and X,Y coordinate and "drop" a line to either the x axis, the y axis or to both.

Here is an example that you should be able run as you should have the SASHELP.CLASS data set:

 

proc sgplot data=sashelp.class;
   scatter x=height y=weight;
   dropline x=60 y=100 / dropto=both;
run;

This uses the BOTH option for drop to. Try it with Dropto=X and Dropto=Y for the others.

 

NP2212
Fluorite | Level 6

I need this type of graph with dotted line

NP2212_0-1726684274426.png

 

ballardw
Super User

@NP2212 wrote:

I need this type of graph with dotted line

NP2212_0-1726684274426.png

 


Which looks a lot like Dropline x=9 y=0.5/ drop2=both lineattrs=(pattern=shortdash) ;

NP2212
Fluorite | Level 6

it worked. thank you so much. 

FreelanceReinh
Jade | Level 19

Hello @NP2212,

Glad to see that @ballardw's solution worked for you. Then it would be fair and help later readers if you marked his helpful reply as the accepted solution, not your own "thank you" post. Could you please change that? It's very easy: Select his post as the solution after clicking "Not the Solution" in the option menu (see icon below) of the current solution.
show_option_menu.png

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
  • 7 replies
  • 525 views
  • 0 likes
  • 3 in conversation