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

Hi, I am using SAS University Edition. I am trying to overlay a KM curve and PH curve to see if they match relatively well. I can overlay them, but the PH curves have lines connecting the starting point and ending point. Can someone help me remove these lines? 

 

proc phreg data=Allhiv33;
class arm;
model (tL,tR)*status(0)=arm;
baseline out=bb covariates=covs survival=s cumhaz=Ht ;
run;

proc lifetest data=allhiv2 outsurv=c ;
time inf_time*delta(0);
strata arm;
run;

data b_new;
set bb;
length Z $27;
if arm="DMPA" then Z="PH DMPA"; 
if arm="IUD" then Z="PH IUD"; 
if arm="Jadelle" then Z="PH Jadelle"; 
run;

data c_new;
set c(rename=(survival=s inf_time=tR));
length Z $27;
if arm="DMPA" then Z="KM DMPA"; 
if arm="IUD" then Z="KM IUD"; 
if arm="Jadelle" then Z="KM Jadelle"; 
run;

data both_arms;
set b_new c_new;
run;

proc sgplot data=both_arms;
series x=tR y=s / group=Z ;
run;
** neither sgplot rids of connecting lines;
proc sgplot data=both_arms;
step y=s x=tR / group=z;
run;

Snip20180422_1.png

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Try sorting the data before you plot it:

 

proc sort data=both_arms;
by Z tR;
run;

View solution in original post

6 REPLIES 6
PGStats
Opal | Level 21

Add missing values to create breaks in the lines:

 

data both_arms;
set b_new c_new;
by Z notsorted;
output;
if last.Z then do;
    call missing(s);
    output;
    end;
run;

proc sgplot data=both_arms;
series x=tR y=s / group=Z break;
run;
PG
mkm063
Fluorite | Level 6

Thanks PG for replying and helping me with this. 

I have tried the suggested code and my problem is still persisting. I am playing around with the break option and trying to set different Y values to missing. Do you think I need to change all values of the last arm or tR (time) for the graph to display correctly. Additionally, maybe I need to also set first values to missing?

Thanks again and any more brain power is appreciated, but obviously not assumed.

Rick_SAS
SAS Super FREQ

Try sorting the data before you plot it:

 

proc sort data=both_arms;
by Z tR;
run;
mkm063
Fluorite | Level 6

Wow- sorting with the break option worked. Thank you both for helping solve this problem!

Rick_SAS
SAS Super FREQ

I don't think you need the missing values or the BREAK option, but I could be mistaken.

mkm063
Fluorite | Level 6

I just tried it again without the break option, and you're right. I just needed to sort my combined dataset. Thanks for the problem solving!

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
  • 6 replies
  • 1232 views
  • 3 likes
  • 3 in conversation