<?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: Insert missing weeks in the table or display missing weeks in the output tables/charts in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854171#M37598</link>
    <description>&lt;P&gt;Please read my post again and answer my question.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 18:23:21 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-01-17T18:23:21Z</dc:date>
    <item>
      <title>Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854047#M37588</link>
      <description>&lt;P&gt;I have a very large data set similar to the following sample data set 'have'. Some weeks are missing (12/10/22, and 01/07/23 in the sample data set) in the data set since there are no values on those weeks. However, I need to show all the weeks during the whole period (12/3/22 to 1/21/23) in an order in the output tables or bar chart (missing weeks will have zero value in the output). How can I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
informat Week mmddyy8.;
input ID   Test $   Week   value $   ;
Format week date7.;
cards;
1 x 12/03/22 Pos 
1 y 12/03/22 pos
2 z 12/17/22 Neg
1 x 12/17/22 Pos 
2 y 12/24/22 pos
3 z 12/24/22 Neg
3 x 12/24/22 Pos 
2 y 12/31/22 pos
3 z 01/14/23 Neg
3 x 01/14/23 Pos 
2 y 01/21/23 pos
3 z 01/21/23 Neg
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 06:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854047#M37588</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2023-01-17T06:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854052#M37589</link>
      <description>&lt;P&gt;Do you need extra observations/lines for each possible test, or is it sufficient to create a single observation for a week where both test and value are missing?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 07:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854052#M37589</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-17T07:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854056#M37590</link>
      <description>&lt;P&gt;Depending on the bar char you want to create, you may not need the obs for missing weeks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select min(Week), max(Week) 
      into :first, :last
      from have;
quit;

proc sgplot data=WORK.HAVE;
   vbar Week /;
   format Week weeku5.;
   yaxis grid;
   xaxis interval= week values=(&amp;amp;first to &amp;amp;last by week);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2023 08:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854056#M37590</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-01-17T08:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854112#M37591</link>
      <description>&lt;P&gt;You should show an example of how you expect to use those missing dates in a report or "output table". Since all of the other variables would be missing it is not obvious to me exactly what you expect to appear any table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A possible approach with some uses is to create a custom format for the expected date values and use a Preloadfmt option with the variable that need those dates. Such a format might be made as:&lt;/P&gt;
&lt;PRE&gt;data cntlinset;
   fmtname="Dateinterval";
   type='N';
   do date='03DEC2022'd to '31Jan2023'd by 7;
      start=date;
      label=put(date,mmddyy8.);
      output;
   end;
   
run;

proc format cntlin=cntlinset;
run;&lt;/PRE&gt;
&lt;P&gt;Strongly suggest if you have any choice to use 4-digit years. It reduces any possibly ambiguity in data that may have long history of values (economic or political) for example, and is just plain easier to read in general. Not to mention that the values become dependent on the setting of system options and might result if different values if code is run on someone else's system that is using a different value for the Yearcutoff option.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 16:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854112#M37591</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-17T16:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854114#M37592</link>
      <description>Wonderful!&lt;BR /&gt;Is it also possible to keep the weeks with no values in the output tables?&lt;BR /&gt;The following code does not include the weeks with no values in the table.&lt;BR /&gt;&lt;BR /&gt;PROC TABULATE data=have;&lt;BR /&gt;CLASS Test Week;&lt;BR /&gt;TABLE Test="" all="Total",  week * N='' all="Total"* N='';&lt;BR /&gt;RUN;</description>
      <pubDate>Tue, 17 Jan 2023 16:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854114#M37592</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2023-01-17T16:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854131#M37593</link>
      <description>Thanks for your question. The original table does not have the weeks where there is no value. But, I need to keep the weeks with no values in the output tables/charts. The solution by andreas_Ids solved  the problem of missing weeks in the chart. Now I am looking for a solution for output tables. &lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jan 2023 16:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854131#M37593</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2023-01-17T16:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854170#M37597</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335985"&gt;@Barkat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Wonderful!&lt;BR /&gt;Is it also possible to keep the weeks with no values in the output tables?&lt;BR /&gt;The following code does not include the weeks with no values in the table.&lt;BR /&gt;&lt;BR /&gt;PROC TABULATE data=have;&lt;BR /&gt;CLASS Test Week;&lt;BR /&gt;TABLE Test="" all="Total", week * N='' all="Total"* N='';&lt;BR /&gt;RUN;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is one of the cases where a PRELOADFMT might be appropriate.&lt;/P&gt;
&lt;P&gt;Look at my other post to create a dateinterval format.&lt;/P&gt;
&lt;P&gt;The Preloadfmt option requires use of a format with a known finite list of values to display, so you can't use the date7 format.&lt;/P&gt;
&lt;P&gt;Then :&lt;/P&gt;
&lt;PRE&gt;PROC TABULATE data=have;
   CLASS Test;
   class Week/missing preloadfmt;
   format week dateinterval. ;
   TABLE Test="" all="Total", 
              week * N='' all="Total"* N='
               /printmiss';
RUN;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854170#M37597</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-17T18:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854171#M37598</link>
      <description>&lt;P&gt;Please read my post again and answer my question.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854171#M37598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-17T18:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854201#M37613</link>
      <description>Thanks for your wonderful answer. Including yours, combinedly, two answers in this post solved my problem. I wish I could accept both as solution.</description>
      <pubDate>Tue, 17 Jan 2023 21:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854201#M37613</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2023-01-17T21:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing weeks in the table or display missing weeks in the output tables/charts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854202#M37614</link>
      <description>Thanks for your wonderful answer. Including yours, combinedly, two answers in this post solved my problem.</description>
      <pubDate>Tue, 17 Jan 2023 21:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Insert-missing-weeks-in-the-table-or-display-missing-weeks-in/m-p/854202#M37614</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2023-01-17T21:20:29Z</dc:date>
    </item>
  </channel>
</rss>

