<?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: PROC PHREG in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-PHREG/m-p/551576#M153263</link>
    <description>&lt;P&gt;Check the distribution of variables when censor = 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS excludes any observations where any variable is missing, so if other variables are missing for your censored observations it will exclude those observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're also overwriting data2 in one of your latter steps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this type of programming style is bad, mostly because it makes it really&amp;nbsp; really hard to find mistakes. Instead, just increment it each time up one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data2; set data2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data3; set data2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is a problem, note you reference data1 so all the other conversions are erased now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* change event b and event ph into numeric */
data data2; set data1;
   event_b = input(event_c, BEST.);
   format event_b BEST.;
   event_ph = input(event_c_ph, BEST.);
   format event_ph BEST.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is also incorrect - I would expect a message in the log or error for these lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if bmipct_chg_b = "RC" then bmipct_chg_b = .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since the variable is character you should use empty quotation marks, or I like to use CALL MISSING, since it doesn't matter if the variable is numeric or character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if bmipct_chg_b = "RC" then call missing(bmipct_chg_b);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Fix the data reference issues, fix the conversion issues and try again. The data reference is a big one in your steps, but this is a logical error, not a syntax error so it's harder to find.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/237115"&gt;@amd23050&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to run PROC PHREG for a Cox Proportional Hazards model. The output is reading 0 censored observations, though the PROC FREQ I ran shows several observations in the 0 (censored) category. Also, it is not recognizing some of the other variables in my model statement, including age_b and age_ph and bmichg_b and bmichg_ph..and also event_b and event_ph. The variable in the error message seems to switch every time. Any ideas why this is happening? Sample code below. Thank you!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* change BMI PCT CHANGE into numeric.*/
data data2; set data1;
if bmipct_chg_b = "RC" then bmipct_chg_b = .;
else if bmipct_chg_ph = "RC" then bmipct_chg_ph = .;
run;

data data2; set data2;
   bmichg_b = input(bmipct_chg_b, BEST.);
   format bmichg_b BEST.;
   bmichg_ph = input(bmipct_chg_ph, BEST.);
   format bmichg_ph BEST.;
run;

proc means data=data2;
var bmichg_b;
var bmichg_ph;
run;

/* change age_chg_b and age_chg_ph into numeric*/
data data2; set data1;
if age_chg_b = "RC" then age_chg_b = .;
else if age_chg_ph = "RC" then age_chg_ph = .;
run;

data data2; set data2;
   age_b = input(age_chg_b, BEST.);
   format age_b BEST.;
   age_ph = input(age_chg_ph, BEST.);
   format age_ph BEST.;
run;

proc means data=data2;
var age_b;
var age_ph; 
run;
/* change event b and event ph into numeric */
data data2; set data1;
   event_b = input(event_c, BEST.);
   format event_b BEST.;
   event_ph = input(event_c_ph, BEST.);
   format event_ph BEST.;
run;

proc freq data=data2;
table event_b;
table event_ph;
run;

/* Confirm: higher BMI and earlier Age At Puberty - Cox Models*/
/* Breast*/
title "BMI Percentile Change and Breast Development";
proc phreg data=data2;
model age_b*event_b(0) = bmichg_b agemos_baseline/risklimits covb ties=efron;
run;
/* PH*/
title "BMI Percentile Change and Pubic Hair Development";
proc phreg data=data2;
model age_ph*event_ph(0)=bmichg_ph agemos_baseline/risklimits covb ties=efron;
run;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Apr 2019 22:29:57 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-04-16T22:29:57Z</dc:date>
    <item>
      <title>PROC PHREG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PHREG/m-p/551567#M153256</link>
      <description>&lt;P&gt;I am trying to run PROC PHREG for a Cox Proportional Hazards model. The output is reading 0 censored observations, though the PROC FREQ I ran shows several observations in the 0 (censored) category. Also, it is not recognizing some of the other variables in my model statement, including age_b and age_ph and bmichg_b and bmichg_ph..and also event_b and event_ph. The variable in the error message seems to switch every time. Any ideas why this is happening? Sample code below. Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* change BMI PCT CHANGE into numeric.*/
data data2; set data1;
if bmipct_chg_b = "RC" then bmipct_chg_b = .;
else if bmipct_chg_ph = "RC" then bmipct_chg_ph = .;
run;

data data2; set data2;
   bmichg_b = input(bmipct_chg_b, BEST.);
   format bmichg_b BEST.;
   bmichg_ph = input(bmipct_chg_ph, BEST.);
   format bmichg_ph BEST.;
run;

proc means data=data2;
var bmichg_b;
var bmichg_ph;
run;

/* change age_chg_b and age_chg_ph into numeric*/
data data2; set data1;
if age_chg_b = "RC" then age_chg_b = .;
else if age_chg_ph = "RC" then age_chg_ph = .;
run;

data data2; set data2;
   age_b = input(age_chg_b, BEST.);
   format age_b BEST.;
   age_ph = input(age_chg_ph, BEST.);
   format age_ph BEST.;
run;

proc means data=data2;
var age_b;
var age_ph; 
run;
/* change event b and event ph into numeric */
data data2; set data1;
   event_b = input(event_c, BEST.);
   format event_b BEST.;
   event_ph = input(event_c_ph, BEST.);
   format event_ph BEST.;
run;

proc freq data=data2;
table event_b;
table event_ph;
run;

/* Confirm: higher BMI and earlier Age At Puberty - Cox Models*/
/* Breast*/
title "BMI Percentile Change and Breast Development";
proc phreg data=data2;
model age_b*event_b(0) = bmichg_b agemos_baseline/risklimits covb ties=efron;
run;
/* PH*/
title "BMI Percentile Change and Pubic Hair Development";
proc phreg data=data2;
model age_ph*event_ph(0)=bmichg_ph agemos_baseline/risklimits covb ties=efron;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Apr 2019 22:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PHREG/m-p/551567#M153256</guid>
      <dc:creator>amd23050</dc:creator>
      <dc:date>2019-04-16T22:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PHREG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PHREG/m-p/551576#M153263</link>
      <description>&lt;P&gt;Check the distribution of variables when censor = 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS excludes any observations where any variable is missing, so if other variables are missing for your censored observations it will exclude those observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're also overwriting data2 in one of your latter steps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this type of programming style is bad, mostly because it makes it really&amp;nbsp; really hard to find mistakes. Instead, just increment it each time up one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data2; set data2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data3; set data2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is a problem, note you reference data1 so all the other conversions are erased now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* change event b and event ph into numeric */
data data2; set data1;
   event_b = input(event_c, BEST.);
   format event_b BEST.;
   event_ph = input(event_c_ph, BEST.);
   format event_ph BEST.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is also incorrect - I would expect a message in the log or error for these lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if bmipct_chg_b = "RC" then bmipct_chg_b = .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since the variable is character you should use empty quotation marks, or I like to use CALL MISSING, since it doesn't matter if the variable is numeric or character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if bmipct_chg_b = "RC" then call missing(bmipct_chg_b);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Fix the data reference issues, fix the conversion issues and try again. The data reference is a big one in your steps, but this is a logical error, not a syntax error so it's harder to find.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/237115"&gt;@amd23050&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to run PROC PHREG for a Cox Proportional Hazards model. The output is reading 0 censored observations, though the PROC FREQ I ran shows several observations in the 0 (censored) category. Also, it is not recognizing some of the other variables in my model statement, including age_b and age_ph and bmichg_b and bmichg_ph..and also event_b and event_ph. The variable in the error message seems to switch every time. Any ideas why this is happening? Sample code below. Thank you!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* change BMI PCT CHANGE into numeric.*/
data data2; set data1;
if bmipct_chg_b = "RC" then bmipct_chg_b = .;
else if bmipct_chg_ph = "RC" then bmipct_chg_ph = .;
run;

data data2; set data2;
   bmichg_b = input(bmipct_chg_b, BEST.);
   format bmichg_b BEST.;
   bmichg_ph = input(bmipct_chg_ph, BEST.);
   format bmichg_ph BEST.;
run;

proc means data=data2;
var bmichg_b;
var bmichg_ph;
run;

/* change age_chg_b and age_chg_ph into numeric*/
data data2; set data1;
if age_chg_b = "RC" then age_chg_b = .;
else if age_chg_ph = "RC" then age_chg_ph = .;
run;

data data2; set data2;
   age_b = input(age_chg_b, BEST.);
   format age_b BEST.;
   age_ph = input(age_chg_ph, BEST.);
   format age_ph BEST.;
run;

proc means data=data2;
var age_b;
var age_ph; 
run;
/* change event b and event ph into numeric */
data data2; set data1;
   event_b = input(event_c, BEST.);
   format event_b BEST.;
   event_ph = input(event_c_ph, BEST.);
   format event_ph BEST.;
run;

proc freq data=data2;
table event_b;
table event_ph;
run;

/* Confirm: higher BMI and earlier Age At Puberty - Cox Models*/
/* Breast*/
title "BMI Percentile Change and Breast Development";
proc phreg data=data2;
model age_b*event_b(0) = bmichg_b agemos_baseline/risklimits covb ties=efron;
run;
/* PH*/
title "BMI Percentile Change and Pubic Hair Development";
proc phreg data=data2;
model age_ph*event_ph(0)=bmichg_ph agemos_baseline/risklimits covb ties=efron;
run;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 22:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PHREG/m-p/551576#M153263</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-16T22:29:57Z</dc:date>
    </item>
  </channel>
</rss>

