<?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: Compute block in Proc Report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912813#M359795</link>
    <description>&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;Instructions and examples&lt;/A&gt; of how to provide sample data as SAS data step code.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jan 2024 12:24:06 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-01-24T12:24:06Z</dc:date>
    <item>
      <title>Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912811#M359793</link>
      <description>&lt;P&gt;Dear Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use compute block in proc report to highlight the response time is greater than 10m mins but still not getting expected output. below is my code&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;proc report data=s1;&lt;BR /&gt;column City_name  Priority,responsetime;&lt;BR /&gt;define city_name/group "DCR Name";&lt;BR /&gt;define priority/across "Priority";&lt;BR /&gt;define responsetime/mean format=time8. "Response Time";&lt;BR /&gt; compute responsetime;&lt;BR /&gt;    if  mean(responsetime)&amp;gt;'00:10:00't then do;&lt;BR /&gt;      call define('responsetime.mean', 'style', 'style=[background=red foreground=white font_weight=bold]');&lt;BR /&gt;    end;&lt;BR /&gt;  endcomp;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;My responsetime is in time8. format only and even I tried by passing numeric value as like&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if mean(responsetime)&amp;gt;600 then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Kindly suggest me for necessary changes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 12:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912811#M359793</guid>
      <dc:creator>SatishR</dc:creator>
      <dc:date>2024-01-24T12:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912812#M359794</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460901"&gt;@SatishR&lt;/a&gt;&amp;nbsp;Not that many people providing answers regularly in this forum use Proc Report that often to just spot "any" issues and to provide untested code changes that then actually also work.&lt;/P&gt;
&lt;P&gt;You will get more people responding with tested code if you provide sample source data and also show us the desired result.&lt;/P&gt;
&lt;P&gt;Please provide sample source data ideally via SAS data step code that creates the sample data that you then use with the Proc Report code - and then show us the desired result or if not feasible describe it as detailed as possible.&lt;/P&gt;
&lt;P&gt;Basically.... If you would be asked to help, what would you like/need to get as information?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 12:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912812#M359794</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-01-24T12:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912813#M359795</link>
      <description>&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;Instructions and examples&lt;/A&gt; of how to provide sample data as SAS data step code.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 12:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912813#M359795</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-24T12:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912817#M359799</link>
      <description>&lt;P&gt;You cannot use an unaliased variable in the COMPUTE, you need to also specify the statistic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if responsetime.mean &amp;gt; '00:10:00't then do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jan 2024 12:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912817#M359799</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-24T12:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912823#M359803</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460901"&gt;@SatishR&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(After a quick look into &lt;A href="https://redshelf.com/app/ecom/book/1878754/carpenters-complete-guide-to-the-sas-report-procedure-1878754-9781599944272-art-carpenter" target="_blank" rel="noopener"&gt;Carpenter's Complete Guide to the SAS REPORT Procedure&lt;/A&gt; ...)&lt;/P&gt;
&lt;P&gt;I think using column number references (&lt;FONT face="courier new,courier"&gt;_c1_&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;_c2_&lt;/FONT&gt;, ...) will work better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; compute responsetime;
    if _c2_&amp;gt;'0:10't then call define('_c2_', 'style', 'style=[background=red foreground=white font_weight=bold]');
    if _c3_&amp;gt;'0:10't then call define('_c3_', 'style', 'style=[background=red foreground=white font_weight=bold]');
    /* ... possibly more of these IF-THEN statements, depending on the number of PRIORITY values ... */
  endcomp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are many distinct PRIORITY values, you may want to switch to the format approach to traffic highlighting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value backgrfmt '0:10't&amp;lt;-high = 'red';
value foregrfmt '0:10't&amp;lt;-high = 'white';
value fontwtfmt '0:10't&amp;lt;-high = 'bold';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you don't even need a COMPUTE block; just add a STYLE option to the appropriate DEFINE statement and refer to the formats:&lt;/P&gt;
&lt;PRE&gt;define responsetime/mean format=time8. "Response Time"
       &lt;STRONG&gt;style(column)=[background=backgrfmt. foreground=foregrfmt. font_weight=fontwtfmt.];&lt;/STRONG&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jan 2024 13:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912823#M359803</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-01-24T13:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912839#M359810</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; is correct. You cannot use the simple &lt;EM&gt;varname.stat&lt;/EM&gt; in a COMPUTE block when the variable is nested under an ACROSS variable. You MUST use the absolute column numbers. There are a lot of previous postings in the forum about using absolute column numbers in a COMPUTE block.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 15:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912839#M359810</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-01-24T15:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912887#M359823</link>
      <description>&lt;P&gt;Best is to provide actual data as working data step.&lt;/P&gt;
&lt;P&gt;I have made some fake data using your variables and an approach to do this with Proc TABULATE and a format to attach to the statistic to set color.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data s1;
  input city_name $ priority $ responsetime :time.;
  format responsetime time.;
datalines;
AAA  first  00:01:00
AAA  first  00:03:00
AAA  first  00:05:00
BBB  first  00:11:00
BBB  first  00:13:00
BBB  first  00:15:00
AAA  last  00:07:00
AAA  last  00:12:00
AAA  last  00:15:00
BBB  last  00:02:00
BBB  last  00:06:00
BBB  last  00:09:00
;

proc format ;
value mycolor
'00:10:00't - high ='red'
;
run;

proc tabulate data=s1;
  class city_name priority;
  var responsetime;
  table city_name,
        priority*responsetime*mean*[style= [backgroundcolor=mycolor.]]*f=time.
  ;
run;&lt;/PRE&gt;
&lt;P&gt;Tabulate behaves a bit differently than Proc report (no compute block at all for one). You can specify style appearance in conjunction with a statistic (or other variable) as shown. The Format evaluates the value that is to be displayed and then uses the resulting value, i.e. anything 10 minutes or greater in the desired color.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 19:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912887#M359823</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-24T19:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912949#M359858</link>
      <description>&lt;P&gt;Hi I have below sample data&amp;nbsp; and I have to highlight avg of resposetime is greater than 10 Minutes in proc report.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data s1;&lt;BR /&gt;input Sr 1-2 City_name $ 3-12 Event_id $ 14-22 Responsetime $ 24-32 Priority $ 33-35;&lt;BR /&gt;cards;&lt;BR /&gt;1 Ahmednagar CFS459872 00:14:00 P1&lt;BR /&gt;2 Ahmednagar CFS462218 00:52:25 P1&lt;BR /&gt;3 Ahmednagar CFS458172 22:48:25 P1&lt;BR /&gt;4 Ahmednagar CFS458822 00:30:09 P1&lt;BR /&gt;5 Ahmednagar CFS461207 00:32:46 P2&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected output shall be like this,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SatishR_0-1706176110704.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92963i4571F14521AD8349/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SatishR_0-1706176110704.png" alt="SatishR_0-1706176110704.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope this input will understand my query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 09:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912949#M359858</guid>
      <dc:creator>SatishR</dc:creator>
      <dc:date>2024-01-25T09:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912966#M359861</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460901"&gt;@SatishR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Expected output shall be like this,&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SatishR_0-1706176110704.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92963i4571F14521AD8349/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SatishR_0-1706176110704.png" alt="SatishR_0-1706176110704.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks for providing sample data and the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's first improve the type of variable &lt;FONT face="courier new,courier"&gt;Responsetime&lt;/FONT&gt;. Your own PROC REPORT code used it as a numeric variable (as it should), but it appears to be a character variable in your sample data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set s1(rename=(responsetime=rt));
Responsetime=input(rt,time8.);
format Responsetime e8601tm.;
drop rt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since '06:06:15't is obviously greater than '00:10:00't, but you didn't highlight it, I assume that you only want to highlight times with priority P2. (If you change your mind and would like to highlight priority-P1 times as well, just add the analogous IF-THEN statement for &lt;FONT face="courier new,courier"&gt;_c2_&lt;/FONT&gt; below; cf. my first reply.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods html file='C:\Temp\want.html' style=pearl;

proc report data=have;
column City_name Responsetime, Priority;
define City_name / group;
define priority / across ' ';
define responsetime / mean format=e8601tm.;
compute responsetime;
  if _c3_&amp;gt;'0:10't then call define('_c3_', 'style', 'style=[background=yellow]');
endcomp;
run;

ods html close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I obtain this table:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Responsetime.png" style="width: 320px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92965iDE2B4AC826DCDE85/image-size/large?v=v2&amp;amp;px=999" role="button" title="Responsetime.png" alt="Responsetime.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 11:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912966#M359861</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-01-25T11:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912989#M359868</link>
      <description>&lt;P&gt;If you want to work with date, time or datetime values, such as calculating intervals, incrementing or things like mean time, range if times or standard deviation then you must use SAS date, time or datetime values which are numeric.&lt;/P&gt;
&lt;P&gt;Your example shows use of "time" as character values. Consider what would the mean of "ABC" , "PDQ" and "XYZ" be? There really isn't a lot of agreement what a "mean" or other calculation for character values would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates and times.&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/460901"&gt;@SatishR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi I have below sample data&amp;nbsp; and I have to highlight avg of resposetime is greater than 10 Minutes in proc report.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data s1;&lt;BR /&gt;input Sr 1-2 City_name $ 3-12 Event_id $ 14-22 Responsetime $ 24-32 Priority $ 33-35;&lt;BR /&gt;cards;&lt;BR /&gt;1 Ahmednagar CFS459872 00:14:00 P1&lt;BR /&gt;2 Ahmednagar CFS462218 00:52:25 P1&lt;BR /&gt;3 Ahmednagar CFS458172 22:48:25 P1&lt;BR /&gt;4 Ahmednagar CFS458822 00:30:09 P1&lt;BR /&gt;5 Ahmednagar CFS461207 00:32:46 P2&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected output shall be like this,&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SatishR_0-1706176110704.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92963i4571F14521AD8349/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SatishR_0-1706176110704.png" alt="SatishR_0-1706176110704.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hope this input will understand my query.&lt;/P&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>Thu, 25 Jan 2024 15:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/912989#M359868</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-25T15:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/913084#M359902</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;, for providing a solution. I have received the answer to my query.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 06:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/913084#M359902</guid>
      <dc:creator>SatishR</dc:creator>
      <dc:date>2024-01-26T06:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compute block in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/913085#M359903</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;Thank you..This solution is also acceptable.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 06:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-block-in-Proc-Report/m-p/913085#M359903</guid>
      <dc:creator>SatishR</dc:creator>
      <dc:date>2024-01-26T06:20:56Z</dc:date>
    </item>
  </channel>
</rss>

