<?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: How to add dynamically weekday column counts in the report as the week progress? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718393#M24858</link>
    <description>Works like a charm.</description>
    <pubDate>Wed, 10 Feb 2021 20:51:10 GMT</pubDate>
    <dc:creator>Stalk</dc:creator>
    <dc:date>2021-02-10T20:51:10Z</dc:date>
    <item>
      <title>How to add dynamically weekday column counts in the report as the week progress?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718316#M24854</link>
      <description>&lt;P&gt;I am working on a report to automatically send daily report to the users with a table in the body of the email. One of the requirement is to have a column for total count, prior week counts and this weeks counts( break down by day).. Not sure how to&amp;nbsp;add the columns as the week progress with their respective header names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;started&amp;nbsp;to get last week dates but not sure how to add the columns in the proc report.. some times there might not be any data for that day but still need to show for the 3 products..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; fdlw=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(intnx(week,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(today()),-1,b),date9.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; first_day=&amp;amp;fdlw ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ldlw=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(intnx(week,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(today()),0,b),date9.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; last_day=&amp;amp;ldlw ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt; &lt;STRONG&gt;REPORT&lt;/STRONG&gt; DATA=daily_Counts nowd HEADLINE HEADSKIP SPLIT='*'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;style (report) = {background = white&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;font_face = "Verdana" font_size = &lt;STRONG&gt;7&lt;/STRONG&gt;pt just=left }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;style (column) = {background = white CELLHEIGHT = &lt;STRONG&gt;2.5&lt;/STRONG&gt;%&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;font_face = "Verdana" font_size = &lt;STRONG&gt;7&lt;/STRONG&gt;pt just=left}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;style (header) = {foreground = cx5e2750 font_face="Verdana"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;font_size = &lt;STRONG&gt;8&lt;/STRONG&gt;pt just=left&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;background = white} ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; column product Description Total_counts Prior_week Day1 Day2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; define Product / display width= &lt;STRONG&gt;15&lt;/STRONG&gt; "Product";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; define Description / display width= &lt;STRONG&gt;30&lt;/STRONG&gt; " Description ";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; define Total_counts / display width= &lt;STRONG&gt;30&lt;/STRONG&gt; " ";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; define prior_week / display width= &lt;STRONG&gt;30&lt;/STRONG&gt; "”;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; define Day1 / display width= &lt;STRONG&gt;30&lt;/STRONG&gt; " ";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;TABLE width="666"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="77"&gt;&lt;STRONG&gt;Product&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="150"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="117"&gt;&lt;STRONG&gt;Total Products in the system&lt;BR /&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="117"&gt;&lt;STRONG&gt;Total Products in the system Received &lt;BR /&gt;Prior week( Sunday to Saturday)&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="125"&gt;&lt;STRONG&gt;Total Products in the system Received Sunday&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="80"&gt;&lt;STRONG&gt;Total Products in the system Received Monday&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1235&lt;/TD&gt;
&lt;TD&gt;Item1&lt;/TD&gt;
&lt;TD&gt;3173&lt;/TD&gt;
&lt;TD&gt;1070&lt;/TD&gt;
&lt;TD&gt;73&lt;/TD&gt;
&lt;TD&gt;34&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5432&lt;/TD&gt;
&lt;TD&gt;Item4&lt;/TD&gt;
&lt;TD&gt;340&lt;/TD&gt;
&lt;TD&gt;96&lt;/TD&gt;
&lt;TD&gt;19&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6574&lt;/TD&gt;
&lt;TD&gt;Item5&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;-&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 10 Feb 2021 17:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718316#M24854</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2021-02-10T17:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamically weekday column counts in the report as the week progress?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718319#M24855</link>
      <description>&lt;P&gt;It's not clear to me what you are asking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean that at a certain day, there are two daily columns and the next day (automatically, without modifying the program) there are three daily columns and the next day (automatically, without modifying the program) there are four daily columns,&amp;nbsp;&lt;EM&gt;etc&lt;/EM&gt;. (in each case with the previous week column)?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 18:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718319#M24855</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-10T18:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamically weekday column counts in the report as the week progress?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718354#M24856</link>
      <description>&lt;P&gt;yes, I am planning to run a daily sas job where it automatically sends email to users with a tabular report having the following columns. Product ,Description, Total_counts ,Prior_week . Prior_week is from Sunday to Saturday last week( Jan31 to Feb 6th) for this entire week. I handled all these 4 columns but thinking how to add week days columns dynamically? For example:&lt;BR /&gt;In addition to the above 4 columns, if the program runs on Sunday it will have 5 columns, i.e additional column saying "Total Products in the system Received Sunday" .. On Monday there will be 6 columns "Total Products in the system Received Monday" and soon until Saturday. On Saturday the report will have 11 columns(4 basic columns + Sunday to Saturday column counts)&lt;BR /&gt;Then The cycle repeats. In the next week's report: Prior_week will have Feb7 to 13 counts and On Sunday it will have 5 columns ( 4 base columns + Sunday) "Total Products in the system Received Sunday".... Sometimes Saturday and Sunday might have 0 counts but still I want to show the columns&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 19:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718354#M24856</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2021-02-10T19:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamically weekday column counts in the report as the week progress?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718367#M24857</link>
      <description>&lt;P&gt;PROC REPORT can add additional columns without additional programming.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMPORTANT CONCEPT: even though you want the output from PROC REPORT to have more columns each day (until it shrinks at the end of the week to fewer columns), you want your DATA set to have more&amp;nbsp;&lt;EM&gt;rows&lt;/EM&gt;&amp;nbsp;as the number of days increases&lt;SPAN style="font-family: inherit;"&gt;. PROC REPORT will figure out how many columns are needed and give you the proper number of columns in the output. See &lt;/SPAN&gt;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 19&lt;/A&gt;&lt;SPAN style="font-family: inherit;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Probably, you will want to do some summarization of the previous week before you get to PROC REPORT. This can be done via PROC SUMMARY, or otherwise. But let's assume you have done this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brief example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input product description $ total last_week day :date9. amount_received;
    cards;
1235    Item1    3173   1070    07FEB2021    73
1235    Item1    3173   1070    08FEB2021    34
5432    Item4    340     96     07FEB2021    19
5432    Item4    340     96     08FEB2021    2
6574    Item5     5       2     08FEB2021    3
;

proc report data=have;
    columns product description total last_week day,amount_received;
    define product/group;
    define description/group;
    define total/mean;
    define last_week/mean;
    define day/across format=downame. order=internal;
    define amount_received/mean;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note that if you increase the data set, by adding more ROWS with other dates, the exact same PROC REPORT table will get wider, without you having to modify PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your task is to feed the proper data set into PROC REPORT, computing last_week via PROC SUMMARY or other method&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 19:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718367#M24857</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-10T19:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamically weekday column counts in the report as the week progress?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718393#M24858</link>
      <description>Works like a charm.</description>
      <pubDate>Wed, 10 Feb 2021 20:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-add-dynamically-weekday-column-counts-in-the-report-as/m-p/718393#M24858</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2021-02-10T20:51:10Z</dc:date>
    </item>
  </channel>
</rss>

