<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Align the output tables and images of Procedures in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Align-the-output-tables-and-images-of-Procedures/m-p/812601#M320634</link>
    <description>ods layout gridded advance=table;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/12/02/matrices-graphs-gridded-layout.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2015/12/02/matrices-graphs-gridded-layout.html&lt;/A&gt;</description>
    <pubDate>Wed, 11 May 2022 11:13:34 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-05-11T11:13:34Z</dc:date>
    <item>
      <title>Align the output tables and images of Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Align-the-output-tables-and-images-of-Procedures/m-p/812579#M320624</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently trying to format my output tables in HTML of PROC LIFETEST.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am able to play around with the font, text size and alignment in side the table. But is there any way I can align the tables in the way I want to? I.e. Position them in different location in the HTML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the code I have right now,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/*TITME TO EVENT ANALYSIS: KAPLAN-MEIER ESTIMATE */

proc format;
value sexFmt
     1 = "male"
     2 = "female";
run;

data os;
format patid 10.;
format sex sexFmt.;
call streaminit(6875687);
do patid = 5213 to 9899;
     sex = rand("integer",1,2);
     event_fl = rand("integer",1,0);
     duration_months = rand("integer",6,120);
     output;
     end;
run;

%macro product_limit_template;

proc template;
source Stat.Lifetest.ProductLimitEstimates;
 define table Stat.Lifetest.ProductLimitEstimates;
    notes "Product-Limit Survival";
    column GrpNumVar GrpChrVar Timelist GenericTime Censor NumberAtRisk ObservedEvents Survival Failure StdErr Failed Left Freq
       GenericIDNumeric GenericIDCharacter;
    header h1;
 
    define h1;
       text "Product-Limit Survival Estimates";
       space = 1;
       spill_margin;
       first_panel;
    end;
    parent = Stat.Lifetest.ProductLimitEstimates0;
 end;
 
 define table Stat.Lifetest.ProductLimitEstimates0;
    notes "Survival and Cumulative Hazard";
    dynamic TimeNDec TimelistNDec NumWidth NumDec;
    column GrpNumVar GrpChrVar Timelist GenericTime Censor NumberAtRisk ObservedEvents Survival Failure StdErr CumHaz StdErrCumHaz
       Failed Left Freq Weight GenericIDNumeric GenericIDCharacter;
    header h1 h2 h3;
 
    define h1;
       text "Survival Function and Cumulative Hazard Rate";
       space = 1;
       spill_margin;
       first_panel;
       just=c;
    end;
 
    define h2;
       text "Product-Limit";
       start = Survival;
       end = StdErr;
       just=c;
    end;
 
    define h3;
       text "Nelson-Aalen";
       start = Cumhaz;
       end = StdErrCumhaz;
       just=c;
    end;
 
    define GrpNumVar;
       dynamic GrpVarLab;
       translate _val_=._ into "";
       label = GrpVarLab;
       id;
       generic;
    end;
 
    define GrpChrVar;
       dynamic GrpVarLab;
       label = GrpVarLab;
       id;
       generic;
    end;
 
    define Timelist;
    	define header t;
       		text "Timelist";
       		vjust=m;
       	end;
       header = t;
       just = c;
       format_width = 8;
       format_ndec = TimelistNDec;
       style = RowHeader;
       id;
	   justify=on;
    end;
 
    define GenericTime;
    	define header t;
    		text "Duration (&amp;amp;duration_type.)";
       		vjust=m;
       	end;
       header=t;
       format_width = 8;
       format_ndec = TimeNDec;
       just = c;
       space = 0;
       style = RowHeader;
       id;
       generic;
	   justify=on;
    end;
 
    define Censor;
       header = " ";
       translate
          _val_=1 into "*",
          _val_=0 into "",
          _val_=. into "";
       format = 1.0;
       id;
    end;
 
    define Survival;
    	define header t;
    		text "Survival";
    		vjust=m;
    	end;
       header = t;
       format = D8.;
       just = c;
	   justify=on;
    end;
 
    define Failure;
    	define header t;
       		text "Failure";
       		vjust=m;
       	end;
       header = t;
       format = D8.;
       just = c;
	   justify=on;
    end;
 
    define StdErr;
    	define header t;
       		text "Survival Standard Error";
       		vjust=m;
       	end;
       header=t;
       format = D8.;
       just = c;
	   justify=on;
    end;
 
    define CumHaz;
       header = ";Cumulative;Hazard;";
       format = D8.;
       just = c;
    end;
 
    define StdErrCumHaz;
       header = ";Cum Haz;Standard;Error";
       format = D8.;
       just = c;
    end;
 
    define Failed;
 
       define header t;
          text ";Number;Failed;";
          just = c;
       end;
       header = t;
       just = c;
       format_width = NumWidth;
       format_ndec = NumDec;
	   justify=on;
    end;
 
    define Left;
 
       define header t;
          text ";Number;Left;";
          just = c;
       end;
       header = t;
       just = c;
       format_width = NumWidth;
       format_ndec = NumDec;
	   justify=on;
    end;
 
    define NumberAtRisk;
 
       define header t;
          text ";Number;at Risk;";
          just = c;
          vjust= middle;
       end;
       header = t;
       just = c;
       format_width = NumWidth;
       format_ndec = NumDec;
    end;
 
    define ObservedEvents;
 
       define header t;
          text ";Observed;Events;";
          just = c;
       end;
       header = t;
       just = c;
       format_width = NumWidth;
       format_ndec = NumDec;
    end;
 
    define Freq;
       header = "Freq";
       format_width = NumWidth;
       format_ndec = NumDec;
    end;
 
    define Weight;
       header = "Weight";
       format = D8.;
    end;
 
    define GenericIDNumeric;
       format = BEST8.;
       generic;
       data_format_override;
    end;
 
    define GenericIDCharacter;
       generic;
    end;
    required_space = 5;
    col_space_max = 4;
    col_space_min = 1;
 end;
 
 define table Base.Template.Table;
 end;

run;

%mend product_limit_template;

%macro km_curve(data=, duration_variable=, event_variable=, censor_value=, 
		duration_type=, timelist=, graph_title=, x_axis_title=, y_axis_title=, 
		stratification_variable=, condition=1, km_curve_tag=);
			
	%product_limit_template;
	
	ods trace on/ listing;
	
	ods html path="/home/u48457160/OS_HTML/";
	ods escapechar="^";
	
	proc odstext;
		h "Time To Event Analysis- Kaplan Meier Estimate"/ style={font_size=10 textdecoration=underline};
	run;
	
	proc odstext;
		h "^S={leftmargin=0.25in} 1. What is Time To Event Analysis?"/ style={font_size=5};
		p 	"Time-to-event analysis is a branch of statistics that studies the amount of time it takes before a particular event occurs, say, 
		death, or failure of a component. Furthermore, the time to event can be measured in days, weeks, years, etc."/style={font_size=5};
		
		h "^S={leftmargin=0.25in} 2. What is Kaplan Meier Estimate?"/ style={font_size=5};
		p "Kaplan-Meier (KM) is non-parametric estimates of survival function that is commonly used to describe 
		survivorship of a study population and to compare two study populations. It is used to estimate and graph survival probabilities as a function of time"/style={font_size=5};
		
		h "^S={leftmargin=0.25in} 3. Vocabulary"/ style={font_size=5};
		
		p"a. Event: Outcome of interest, for e.g., death, disease occurrence etc ^n
			b. Observation time: The time until which a subject’s activities has been captured ^n
			c. Censoring: If a subject does not have an event during the observation time, they are censored (nothing is observed or known about that subject after the time of censoring) ^n
			d. Right censoring: This is done if a subject leaves the study before the event occurs ^n
			e. Left censoring: This is done if the event in interest happens before the start of the study ^n
			f. Interval censoring: This is done if they don’t know when exactly the event has occurred but know at what period it has occurred ^n
			g. Survival probability: It is also known as the survivor function S(t), is the probability that an individual survives from the time of origin to a specified future time t ^n
			h. Median survival: It is the point in time where half the patient population has survived ^n
			i. Mean survival: Mean KM estimates are calculated by finding the area under the KM curve
			 "/ style={font_size=5};
		
	run;
	
	title1 height=10 underlin=1 justify=left "^S={leftmargin=0.25in} Result Generation" ;
	title2 height=5 underlin=1 justify=left "^n ^S={leftmargin=0.25in} &amp;amp;graph_title." ;
	
	proc lifetest data=&amp;amp;data. method=km plots=survival(cb=hw test atrisk) 
			timelist=&amp;amp;timelist.;
		%if (&amp;amp;stratification_variable.) ne '' %then
			%do;
				strata &amp;amp;stratification_variable.;
			%end;
		time &amp;amp;duration_variable.*&amp;amp;event_variable.(&amp;amp;censor_value.);
		where &amp;amp;condition.;
		ods output quartiles=quartiles;
		ods output means=means;
		ods output censoredsummary=censoredsummary;
		ods output productlimitestimates=productlimitestimates;
	run;
		
	title1;
	title2;
	
	ods html close;
	
	ods trace off;
			
%mend km_curve;

%km_curve(data=os, duration_variable=duration_months, 
	event_variable=event_fl, censor_value=0, duration_type=months, timelist=12 24 
	36 48 60, graph_title=OS for All patients, x_axis_title=Time to Event (Month), 
	y_axis_title=Survival Prob, stratification_variable=, condition=, 
	km_curve_tag=);
&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 May 2022 09:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Align-the-output-tables-and-images-of-Procedures/m-p/812579#M320624</guid>
      <dc:creator>sam_sas2</dc:creator>
      <dc:date>2022-05-11T09:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Align the output tables and images of Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Align-the-output-tables-and-images-of-Procedures/m-p/812601#M320634</link>
      <description>ods layout gridded advance=table;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/12/02/matrices-graphs-gridded-layout.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2015/12/02/matrices-graphs-gridded-layout.html&lt;/A&gt;</description>
      <pubDate>Wed, 11 May 2022 11:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Align-the-output-tables-and-images-of-Procedures/m-p/812601#M320634</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-11T11:13:34Z</dc:date>
    </item>
  </channel>
</rss>

