<?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: Make PROC SQL display rows with missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765696#M242542</link>
    <description>&lt;P&gt;What is a "note&amp;nbsp; range"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please list the variable(s) by name that have missing values.&lt;/P&gt;
&lt;P&gt;Best would be to provide a small example data set in the form of data step code that shows the behavior you describe &lt;STRONG&gt;and&lt;/STRONG&gt; a second data set showing what you expect for the result. Then we can test with data whether a proposed solution creates the desired output.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Sep 2021 17:42:05 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-09-02T17:42:05Z</dc:date>
    <item>
      <title>Make PROC SQL display rows with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765692#M242539</link>
      <description>&lt;P&gt;I am having issues to make PROC SQL shows rows with missing values. For example, I have 8 note ranges and some note range has no values when I aggregate it but I want to display all 8 note ranges for each product even though it has no values. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table summary as&lt;BR /&gt;select&lt;BR /&gt;as_of_date&lt;BR /&gt;,Channel&lt;BR /&gt;,QRM_Prod&lt;BR /&gt;,Note_Range&lt;BR /&gt;,sum(before_upb) as before_upb&lt;BR /&gt;,sum(after_UPB) as after_UPB&lt;BR /&gt;,sum(before_pmt) as before_pmt&lt;BR /&gt;,sum(after_pmt) as after_pmt&lt;/P&gt;
&lt;P&gt;from msr_act_202102_202107&lt;BR /&gt;group by as_of_date&lt;BR /&gt;,Channel&lt;BR /&gt;,QRM_Prod&lt;BR /&gt;,Note_Range&lt;BR /&gt;order by as_of_date&lt;BR /&gt;,Channel&lt;BR /&gt;,QRM_Prod&lt;BR /&gt;,Note_Range&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 17:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765692#M242539</guid>
      <dc:creator>tampham92</dc:creator>
      <dc:date>2021-09-02T17:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Make PROC SQL display rows with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765696#M242542</link>
      <description>&lt;P&gt;What is a "note&amp;nbsp; range"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please list the variable(s) by name that have missing values.&lt;/P&gt;
&lt;P&gt;Best would be to provide a small example data set in the form of data step code that shows the behavior you describe &lt;STRONG&gt;and&lt;/STRONG&gt; a second data set showing what you expect for the result. Then we can test with data whether a proposed solution creates the desired output.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 17:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765696#M242542</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-02T17:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Make PROC SQL display rows with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765705#M242544</link>
      <description>So you want an entry for NOTE_RANGE=8 say, when the dataset has no records with a value of NOTE_RANGE=8?&lt;BR /&gt;If there are no entries with NOTE_RANGE=8 how would SAS know it needs to exist? Or that you don't need NOTE_RANGE=9, 10, or 100?&lt;BR /&gt;&lt;BR /&gt;You can create a master list and merge that with the data so you'll get missing values but you have to have a data set somewhere that has all the values. &lt;BR /&gt;If not using SQL, preloadformat and classdata are options to handle this using proc means or tabulate, which would work fine for this use case.</description>
      <pubDate>Thu, 02 Sep 2021 19:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765705#M242544</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-02T19:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Make PROC SQL display rows with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765729#M242555</link>
      <description>&lt;P&gt;Use a cross product to create all possible combinations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table summary as
select
	a.as_of_date
	,a.Channel
	,a.QRM_Prod
	,b.Note_Range
	,sum(c.before_upb) as before_upb
	,sum(c.after_UPB) as after_UPB
	,sum(c.before_pmt) as before_pmt
	,sum(c.after_pmt) as after_pmt

from 
	(select distinct
	 as_of_date
	 ,Channel
	 ,QRM_Prod
	 from msr_act_202102_202107) as a cross join
	 
	(select distinct  
	 Note_Range 
	 from msr_act_202102_202107) as b left join
	 
	msr_act_202102_202107 as c on 
		a.as_of_date=c.as_of_date and 
		a.Channel=c.Channel and 
		a.QRM_Prod=c.QRM_Prod and
		b.Note_Range=c.Note_Range

group by 
	a.as_of_date
	,a.Channel
	,a.QRM_Prod
	,b.Note_Range
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 20:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-PROC-SQL-display-rows-with-missing-values/m-p/765729#M242555</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-09-02T20:25:33Z</dc:date>
    </item>
  </channel>
</rss>

