BookmarkSubscribeRSS Feed
lorenzo_moraes
Calcite | Level 5

Hi, I want to plot a line in a specific value of x axis in a survivalplot, I tried to use an annotate data to do it. As you can see in my annotation data, that I call "anno", I using the 'LINE' function, but it is not working the way I want! I want to use my data values in the coordinates of the line, but when I put any drawspace with exception of the "GRAPHPERCENT", the function apparently does not work, any idea of what is wrong with my script?  Here is my sas code:

 

data sp;
	set sashelp.BMT;
run;


proc sgrender data=sp template=Stat.Lifetest.Graphics.ProductLimitSurvival; run;


ods document name=MyDoc(write); 
proc lifetest data=sashelp.BMT plots=survival(cb=hw test); 
	ods output survivalplot=sp; 
	ods select survivalplot; 
	time T * Status(0); 
	strata Group; 
run; 
ods document close;

proc document name=MyDoc; 
	list/levels=all; 
quit;

proc document name=MyDoc; 
	ods output dynamics=outdynam; 
	obdynam \Lifetest#1\SurvivalPlot#1; 
quit;

data anno;
	 length label $100 function fillcolor linecolor $25;
	 retain drawspace 'datavalue' linethickness 3 display 'ALL'
	 widthunit 'data' heightunit 'data' anchor 'left';

	Function ='LINE'; x1 =	500;	y1 = 0.2;	x2 = 500;	y2 = 0.8; linecolor='black'; fillcolor='black';*drawspace='datavalue';
	output;
run;


proc print noobs; 
run;


%ProvideSurvivalMacros

%macro StmtsBeginGraph; annotate; %mend; 

%CompileSurvivalTemplates



proc template; 
	source Stat.Lifetest.Graphics.ProductLimitSurvival / file='temp.tmp'; 
quit;



data _null_; 
	infile 'temp.tmp'; 
	input; 
	if _n_ = 1 then call execute('proc template;'); 
	call execute(_infile_); 
	if _infile_ =: 'BeginGraph' then bg + 1; 
	if bg and index(_infile_,';') then do; 
		bg = 0; 
		call execute('annotate;'); 
	end; 
run;


data _null_; 
	set outdynam(where=(label1 ne '___NOBS___')) end=eof; 
	if nmiss(nvalue1) and cvalue1= '.' then cvalue1= ' '; 
	if _n_ = 1 then do; 
		call execute('proc sgrender data=sp sganno=anno'); 
		call execute('template=Stat.Lifetest.Graphics.ProductLimitSurvival;'); 
		call execute('dynamic'); 
	end; 
	if label1 = 'Transparency' then cvalue1 = '0.9'; 
	if cvalue1 ne ' ' then 
		call execute(catx(' ', label1, '=', 
					ifc(n(nvalue1), cvalue1, quote(trim(cvalue1))))); 
	if eof then call execute('; run;'); 
run;

proc sgrender data=sp sganno=anno 
			template=Stat.Lifetest.Graphics.ProductLimitSurvival; 
	dynamic NSTRATA = 3 PLOTATRISK = 0 PLOTHW = 1 PLOTEP = 0 PLOTCL=0 
		PLOTCENSORED = 1 Transparency = 0.9 PLOTTEST = 1 PVALUE = 0.0010059117 
		METHOD = "Product-Limit" XNAME = "T" LABELHW = "95% Hall-Wellner Band" 
		SECONDTITLE="With 95% Hall-Wellner Bands" GROUPNAME = "DiseaseGroup" 
		TESTNAME="Logrank"; 
run;

proc template; 
	delete Stat.Lifetest.Graphics.ProductLimitSurvival; 
quit;



Im following this PharmaSUG2016 documentation:

 

 

2 REPLIES 2
WarrenKuhfeld
Ammonite | Level 13

I'll try to look over what you are doing tomorrow. In the mean time, you should know that this is the latest version of the KM plot modification examples.  https://support.sas.com/documentation/onlinedoc/stat/151/kaplan.pdf

WarrenKuhfeld
Ammonite | Level 13

In the KM chapter I mentioned, find the section "Adding a Custom Header above the At-Risk Table". It provides a basic illustration of annotation. The text mentions annotation statements.  In SG plotting procedures (not relevant here but mentioned to provide context), you provide an annotation data set. In a graph template and SGRENDER, you provide annotation statements.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 682 views
  • 0 likes
  • 2 in conversation