<?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: phreg format legend values in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446052#M23374</link>
    <description>&lt;P&gt;Have you tried applying a format? That would be my usual recommendation, not sure it changes if using PROC SGRENDER.&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/151035"&gt;@NadiaK&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been working on survival analysis for a while now and it's been a long and painful process in SAS.&lt;/P&gt;
&lt;P&gt;Any, I learned how to format the axis and titles of the plots generated. However, I would now like to format the legend values. I basically have four lines on my plot for the 4 treatments investigated. Instead of these treatments appearing as 1, 2 , 3 and 4, I would like to label them properly. Any ideas on how to do that? Below is the code that I've used so far. I think I should add some proc commands in there to do what I want to do, but don't know how or where.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
define statgraph Stat.PHReg.Graphics.Survival;
   dynamic title1 title2 title3 title4 xviewMin xviewMax group groupIndex groupName plotCL plotHPD
      transparency piecewise _byline_ _bytitle_ _byfootnote_;
   BeginGraph;
      entrytitle "Survival with BC by soft drink consumption" TITLE3;
      entrytitle TITLE2 TITLE4 / textattrs=GRAPHVALUETEXT;
      layout overlay / xaxisopts=(linearopts=(viewmin=XVIEWMIN viewmax=XVIEWMAX)) yaxisopts=(label=
         "All-cancer Survival Probability" shortlabel="All-cancer Survival" linearopts=(viewmin=0.5 viewmax=1 tickvaluelist=(
         0 .2 .4 .6 .8 1.0)));
         if (PLOTCL)
            bandplot LimitLower=LOWERSURVIVAL LimitUpper=UPPERSURVIVAL x=TIME / group=GROUP index=
               GROUPINDEX modelname="Survival" datatransparency=transparency;
         endif;
         if (PLOTHPD)
            bandplot LimitLower=LOWERHPDSURVIVAL LimitUpper=UPPERHPDSURVIVAL x=TIME / group=GROUP
               index=GROUPINDEX modelname="Survival" datatransparency=transparency;
         endif;
         if (EXISTS(PIECEWISE))
            seriesplot y=SURVIVAL x=TIME / group=GROUP index=GROUPINDEX name="Survival";
         else
            stepplot y=SURVIVAL x=TIME / group=GROUP index=GROUPINDEX name="Survival";
         endif;
         if (EXISTS(GROUP))
            discretelegend "Survival" / location=inside title="Freq. of soft drinks" &lt;BR /&gt;                 autoalign=(Bottom BottomLeft Top TopRight);
         endif;
      endlayout;
      if (_BYTITLE_)
         entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
      else
         if (_BYFOOTNOTE_)
            entryfootnote halign=left _BYLINE_;
         endif;
      endif;
   EndGraph;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Mar 2018 02:57:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-16T02:57:46Z</dc:date>
    <item>
      <title>phreg format legend values</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446044#M23373</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been working on survival analysis for a while now and it's been a long and painful process in SAS.&lt;/P&gt;&lt;P&gt;Any, I learned how to format the axis and titles of the plots generated. However, I would now like to format the legend values. I basically have four lines on my plot for the 4 treatments investigated. Instead of these treatments appearing as 1, 2 , 3 and 4, I would like to label them properly. Any ideas on how to do that? Below is the code that I've used so far. I think I should add some proc commands in there to do what I want to do, but don't know how or where.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
define statgraph Stat.PHReg.Graphics.Survival;
   dynamic title1 title2 title3 title4 xviewMin xviewMax group groupIndex groupName plotCL plotHPD
      transparency piecewise _byline_ _bytitle_ _byfootnote_;
   BeginGraph;
      entrytitle "Survival with BC by soft drink consumption" TITLE3;
      entrytitle TITLE2 TITLE4 / textattrs=GRAPHVALUETEXT;
      layout overlay / xaxisopts=(linearopts=(viewmin=XVIEWMIN viewmax=XVIEWMAX)) yaxisopts=(label=
         "All-cancer Survival Probability" shortlabel="All-cancer Survival" linearopts=(viewmin=0.5 viewmax=1 tickvaluelist=(
         0 .2 .4 .6 .8 1.0)));
         if (PLOTCL)
            bandplot LimitLower=LOWERSURVIVAL LimitUpper=UPPERSURVIVAL x=TIME / group=GROUP index=
               GROUPINDEX modelname="Survival" datatransparency=transparency;
         endif;
         if (PLOTHPD)
            bandplot LimitLower=LOWERHPDSURVIVAL LimitUpper=UPPERHPDSURVIVAL x=TIME / group=GROUP
               index=GROUPINDEX modelname="Survival" datatransparency=transparency;
         endif;
         if (EXISTS(PIECEWISE))
            seriesplot y=SURVIVAL x=TIME / group=GROUP index=GROUPINDEX name="Survival";
         else
            stepplot y=SURVIVAL x=TIME / group=GROUP index=GROUPINDEX name="Survival";
         endif;
         if (EXISTS(GROUP))
            discretelegend "Survival" / location=inside title="Freq. of soft drinks" &lt;BR /&gt;                 autoalign=(Bottom BottomLeft Top TopRight);
         endif;
      endlayout;
      if (_BYTITLE_)
         entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
      else
         if (_BYFOOTNOTE_)
            entryfootnote halign=left _BYLINE_;
         endif;
      endif;
   EndGraph;
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 02:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446044#M23373</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2018-03-16T02:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: phreg format legend values</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446052#M23374</link>
      <description>&lt;P&gt;Have you tried applying a format? That would be my usual recommendation, not sure it changes if using PROC SGRENDER.&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/151035"&gt;@NadiaK&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been working on survival analysis for a while now and it's been a long and painful process in SAS.&lt;/P&gt;
&lt;P&gt;Any, I learned how to format the axis and titles of the plots generated. However, I would now like to format the legend values. I basically have four lines on my plot for the 4 treatments investigated. Instead of these treatments appearing as 1, 2 , 3 and 4, I would like to label them properly. Any ideas on how to do that? Below is the code that I've used so far. I think I should add some proc commands in there to do what I want to do, but don't know how or where.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
define statgraph Stat.PHReg.Graphics.Survival;
   dynamic title1 title2 title3 title4 xviewMin xviewMax group groupIndex groupName plotCL plotHPD
      transparency piecewise _byline_ _bytitle_ _byfootnote_;
   BeginGraph;
      entrytitle "Survival with BC by soft drink consumption" TITLE3;
      entrytitle TITLE2 TITLE4 / textattrs=GRAPHVALUETEXT;
      layout overlay / xaxisopts=(linearopts=(viewmin=XVIEWMIN viewmax=XVIEWMAX)) yaxisopts=(label=
         "All-cancer Survival Probability" shortlabel="All-cancer Survival" linearopts=(viewmin=0.5 viewmax=1 tickvaluelist=(
         0 .2 .4 .6 .8 1.0)));
         if (PLOTCL)
            bandplot LimitLower=LOWERSURVIVAL LimitUpper=UPPERSURVIVAL x=TIME / group=GROUP index=
               GROUPINDEX modelname="Survival" datatransparency=transparency;
         endif;
         if (PLOTHPD)
            bandplot LimitLower=LOWERHPDSURVIVAL LimitUpper=UPPERHPDSURVIVAL x=TIME / group=GROUP
               index=GROUPINDEX modelname="Survival" datatransparency=transparency;
         endif;
         if (EXISTS(PIECEWISE))
            seriesplot y=SURVIVAL x=TIME / group=GROUP index=GROUPINDEX name="Survival";
         else
            stepplot y=SURVIVAL x=TIME / group=GROUP index=GROUPINDEX name="Survival";
         endif;
         if (EXISTS(GROUP))
            discretelegend "Survival" / location=inside title="Freq. of soft drinks" &lt;BR /&gt;                 autoalign=(Bottom BottomLeft Top TopRight);
         endif;
      endlayout;
      if (_BYTITLE_)
         entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
      else
         if (_BYFOOTNOTE_)
            entryfootnote halign=left _BYLINE_;
         endif;
      endif;
   EndGraph;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 02:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446052#M23374</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T02:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: phreg format legend values</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446055#M23375</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not very familiar with SAS language. What do you mean by applying a format? Can you give me an example?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 03:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446055#M23375</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2018-03-16T03:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: phreg format legend values</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446409#M23380</link>
      <description>&lt;P&gt;This is an example of how you create a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value dx_fmt
1 = 'Cancer'
2 = 'Heart'
3 = 'Diabetes'
4 = 'Multiple Conditions';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you apply the format using a FORMAT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format variableName dx_fmt.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A full example here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value dx_fmt
1 = 'Cancer'
2 = 'Heart'
3 = 'Diabetes'
4 = 'Multiple Conditions'
other = 'Everything Else';
run;

data demo;
input dx;
cards;
1
2
3
4
5
6 
7
8
9

;
run;

title 'Printed without a format';
proc print data=demo;
run;

title 'Printed with a format';
proc print data=demo;
format dx dx_fmt.;
run;

*example of how its handled in a summary proc;
proc freq data=demo;
table dx;
format dx dx_fmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Mar 2018 01:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/phreg-format-legend-values/m-p/446409#M23380</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-17T01:56:47Z</dc:date>
    </item>
  </channel>
</rss>

