<?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 insert missing records into a table? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119860#M10403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming you have a dataset which consists of the list of storenames, you can do this with either a data step merge or proc sql left join.&amp;nbsp; Here is example code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data table_for_report;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge table_list (keep = store_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sales_table(keep = store_name sales)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by store_name ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if sales = . then sales = 0 ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is important that the table_list be the first table in the merge statement.&amp;nbsp; A record will be create for each value of store_name which is in either table.&amp;nbsp; The table will have a sales column which will be filled with the sales values from the second table when that store is in the sales table.&amp;nbsp; otherwise it will have a missing value.&amp;nbsp; Then the if statement converts the missing value to a value of 0.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Nov 2012 19:21:15 GMT</pubDate>
    <dc:creator>LarryWorley</dc:creator>
    <dc:date>2012-11-07T19:21:15Z</dc:date>
    <item>
      <title>How to insert missing records into a table?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119859#M10402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have this situation where I generate a simple two column table like so:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="150" style="border: 1px solid rgb(0, 0, 0); width: 311px; height: 99px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;store_name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;store1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;70&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store6&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;55&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However in the report I need to have the values for store3 and store5 set to zero like below:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="150" style="border: 1px solid #000000; width: 311px; height: 99px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="padding: 2px; text-align: center; color: #ffffff; background-color: #6690bc;" valign="middle"&gt;&lt;STRONG&gt;store_name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="padding: 2px; text-align: center; color: #ffffff; background-color: #6690bc;" valign="middle"&gt;&lt;STRONG&gt;sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;best&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;70&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;store6&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;55&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do have all the names of all the stores that need to be put in the report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 18:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119859#M10402</guid>
      <dc:creator>BigD</dc:creator>
      <dc:date>2012-11-07T18:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert missing records into a table?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119860#M10403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming you have a dataset which consists of the list of storenames, you can do this with either a data step merge or proc sql left join.&amp;nbsp; Here is example code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data table_for_report;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge table_list (keep = store_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sales_table(keep = store_name sales)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by store_name ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if sales = . then sales = 0 ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is important that the table_list be the first table in the merge statement.&amp;nbsp; A record will be create for each value of store_name which is in either table.&amp;nbsp; The table will have a sales column which will be filled with the sales values from the second table when that store is in the sales table.&amp;nbsp; otherwise it will have a missing value.&amp;nbsp; Then the if statement converts the missing value to a value of 0.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 19:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119860#M10403</guid>
      <dc:creator>LarryWorley</dc:creator>
      <dc:date>2012-11-07T19:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert missing records into a table?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119861#M10404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; In addition, if you use PROC REPORT (or PROC TABULATE) you can get rows populated automatically to 0 by using simple procedure options. See the output from PROC REPORT below in #1. The data does not have any 16 year olds where SEX=F. Yet, because I use the COMPLETEROWS option, the row with 0 for 16 and F is put into the table automatically (without needing an external DATA step program).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Or, if I have a user-defined FORMAT, then I can use COMPLETEROWS with PRELOADFMT (see the rows for 17 and 18 in the output #2). PROC TABULATE has similar, but slightly different syntax available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html file='c:\temp\report_completerows.html' style=sasweb;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=sashelp.class nowd completerows;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '1) Use COMPLETEROWS only';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column sex age n pctn;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define sex / group;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define age / group;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define n / 'Count';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define pctn / 'Percent' f=percent9.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc format;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; value agef 11='11'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12='12'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13='13'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14='14'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15='15'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16='16'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17='17'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 18='18';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=sashelp.class nowd completerows;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '2) Use PRELOADFMT with COMPLETEROWS';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column sex age n pctn;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define sex / group;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define age / group f=agef. preloadfmt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define n / 'Count';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define pctn / 'Percent' f=percent9.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html close;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 21:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119861#M10404</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-11-07T21:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert missing records into a table?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119862#M10405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Larry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't tell you how many times I'm deleting extra records that I don't need from merges, and here they are the solution.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 13:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119862#M10405</guid>
      <dc:creator>BigD</dc:creator>
      <dc:date>2012-11-08T13:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert missing records into a table?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119863#M10406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Cynthia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll have to remember this for next time...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 13:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-insert-missing-records-into-a-table/m-p/119863#M10406</guid>
      <dc:creator>BigD</dc:creator>
      <dc:date>2012-11-08T13:25:47Z</dc:date>
    </item>
  </channel>
</rss>

