<?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: PDF report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950092#M371571</link>
    <description>Better post your FULL code and sample data.&lt;BR /&gt;And you need use keyword _col_ not col:&lt;BR /&gt;&lt;BR /&gt;call define(_col_, 'style', 'style={background=cyan}');</description>
    <pubDate>Thu, 07 Nov 2024 02:19:48 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-11-07T02:19:48Z</dc:date>
    <item>
      <title>PDF report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950090#M371569</link>
      <description>&lt;P&gt;I am using following code to color code the data for pdf report, but it's not working well. These are character variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;compute ORG;&lt;BR /&gt;if ORG &amp;lt; LB_2 then do;&lt;BR /&gt;call define(col, 'style', 'style={background=cyan}'); /* Set background to blue /&lt;BR /&gt;end;&lt;BR /&gt;else if ORG &amp;gt; UB_2 then do;&lt;BR /&gt;call define(col, 'style', 'style={background=red}'); / Set background to red /&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;call define(col, 'style', 'style={background=white}'); / Optional: set to default */&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 01:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950090#M371569</guid>
      <dc:creator>sum_sand</dc:creator>
      <dc:date>2024-11-07T01:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: PDF report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950092#M371571</link>
      <description>Better post your FULL code and sample data.&lt;BR /&gt;And you need use keyword _col_ not col:&lt;BR /&gt;&lt;BR /&gt;call define(_col_, 'style', 'style={background=cyan}');</description>
      <pubDate>Thu, 07 Nov 2024 02:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950092#M371571</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-11-07T02:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: PDF report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950132#M371586</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;ods path (prepend) work.template(update) sashelp.tmplmst;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc template;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;define style custom_style;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; parent=styles.pearl;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; style Document /&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;margin=0.3in;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; style Table /&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bordercolor=cxB0B7BB&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;borderwidth=0.5pt&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;borderstyle=solid;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; class Header /&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;backgroundcolor=lightblue height=40; /* Optional: Change header background color */&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; class fonts /&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; 'TitleFont' = ("&amp;lt;MTsans-serif&amp;gt;, Albany",14pt,bold)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; 'TitleFont2' = ("&amp;lt;MTsans-serif&amp;gt;, Albany",14pt,medium italic)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'docFont' = ("&amp;lt;MTsans-serif&amp;gt;, Albany",8pt);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;end;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;%let tdate = %sysfunc(date(),mmddyy10.);&lt;BR /&gt;%let ttime= %sysfunc(time(),timeampm11.);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;title; /* Clear any existing titles */&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;options nodate nonumber orientation=landscape papersize=letter&amp;nbsp; topmargin=.25in bottommargin=.25in leftmargin=.25in rightmargin=.25in;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Generate PDF report */&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ods pdf file="&amp;amp;path.\&amp;amp;_USERORG..pdf"&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;notoc&lt;/DIV&gt;&lt;DIV&gt;style=custom_style&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;startpage=no;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;/* Create the report */&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;proc report data=_&amp;amp;Have. nowd;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; title H=2.0 J=C&amp;nbsp; 'Birth Data Reporting';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; title2 H=2.0 J=C&amp;nbsp; color=blue "&amp;amp;_USERORG.";&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;title3 H=3.0 ;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;title4 H=3.0 J=C F='Arial' "&amp;amp;tdate &amp;amp;ttime";&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; /* Adjust column widths */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DEFINE CA / STYLE(column)={width=1.5cm};&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DEFINE ORG / STYLE(column)={width=1.5cm};&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DEFINE LAST_60 / STYLE(column)={width=1.5cm};&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DEFINE LAST_60_120 / STYLE(column)={width=1.5cm};&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DEFINE LB_2 / 'LB' STYLE(column)={width=1.5cm};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DEFINE UB_2 / 'UB' STYLE(column)={width=1.5cm};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;compute ORG;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if ORG &amp;lt; LB_2 then call define(_col_, 'style', 'style={background=cyan}');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;else if ORG &amp;gt; UB_2 then call define (_col_, 'style', 'style={background=red}');&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;endcomp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;ods pdf close;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Nov 2024 16:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950132#M371586</guid>
      <dc:creator>sum_sand</dc:creator>
      <dc:date>2024-11-07T16:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: PDF report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950152#M371587</link>
      <description>&lt;P&gt;The order of columns in Proc Report is critical when trying to use column items in Compute blocks. Proc Report builds the report from left to right. So a column such as ORG cannot "see" variables that are in columns to the right of Org, such as LB_2 or UB_2. So the comparisons basically fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that without a Columns statement the order of columns is variable order in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typical solutions would involve one of:&lt;/P&gt;
&lt;P&gt;1) change the order of the columns using a COLUMNS statement so LB_2 and UB_2 appear to the left of ORG&lt;/P&gt;
&lt;P&gt;2) add additional variables to the data set with values of Lb_2 and Ub_2, have them appear in the column order before Org so they can be used. Have the NOPRINT option set in their defines so the column doesn't actually appear in the report body.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of approach 1 with a data set you should have available to test the code.&lt;/P&gt;
&lt;PRE&gt;proc report data=sashelp.class;
   columns sex name ;
   compute name;
      if sex='F' then call define(_col_,'style', 'style={background=pink}');
      else if sex='M'  then call define(_col_, 'style', 'style={background=cyan}');
   endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;Do note that this does not color anything:&lt;/P&gt;
&lt;PRE&gt;proc report data=sashelp.class;
   compute name;
      if sex='F' then call define(_col_,'style', 'style={background=pink}');
      else if sex='M'  then call define(_col_, 'style', 'style={background=cyan}');
   endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of approach 2 adding a variable in a data step to use with Noprint;&lt;/P&gt;
&lt;PRE&gt;data work.class;
   set sashelp.class;
   dummy_sex = sex;
run;

proc report data=work.class;
   columns dummy_sex name sex;
   define dummy_sex / noprint;
   compute name;
      if dummy_sex='F' then call define(_col_,'style', 'style={background=pink}');
      else if dummy_sex='M'  then call define(_col_, 'style', 'style={background=cyan}');
   endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;There might be other approaches but without data it is hard to say.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 17:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950152#M371587</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-11-07T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: PDF report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950162#M371589</link>
      <description>&lt;P&gt;Thank you! Changing column order worked!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 18:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PDF-report/m-p/950162#M371589</guid>
      <dc:creator>sum_sand</dc:creator>
      <dc:date>2024-11-07T18:01:47Z</dc:date>
    </item>
  </channel>
</rss>

