<?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: PROC SQL not displaying rows where all values are missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496803#M131491</link>
    <description>&lt;P&gt;Do you want to accomplish this in one pass of sql when there are no records that fall to the other age category with the existing set up?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am thinking , how about &lt;STRONG&gt;cntlin&lt;/STRONG&gt; your proc format and apply as you did&amp;nbsp; and create &lt;STRONG&gt;cntlout&lt;/STRONG&gt;&amp;nbsp; of the proc format full set and join the two in the same query ? Sorry if this doesn't make sense.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2018 02:45:22 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-19T02:45:22Z</dc:date>
    <item>
      <title>PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496802#M131490</link>
      <description>&lt;P&gt;Release is 9.4.&amp;nbsp; I'm using PROC FORMAT to map a continuous variable into groups.&amp;nbsp; The format has 4 levels while the input data values fall into 2 of the 4 levels.&amp;nbsp;&amp;nbsp;I want PROC SQL to display all 4 rows including rows where all values for the aggregation functions are missing.&amp;nbsp; Instead I get just 2 rows.&amp;nbsp; How do I get PROC SQL to display the rows where all values for the row are missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data df;
infile cards dlm = ',';
length district $ 3
       sector $ 5
	   name $ 8;
input district $
      sector $
	  name $
	  pre
	  post
	  age;
list;
datalines; 
I,   North, Patton,   17,  27,  22
I,   South, Joyner,   13,  22,  19
I,   East,  Williams, 111, 121, 29
I,   West,  Jurat,    51,  55,  22
II,  North, Aden,     71,  70,  17
II,  South, Tanner,   113, 122, 32
II,  East,  Jenkins,  99,  99,  24
II,  West,  Milner,   15,  65,  22
III, North, Chang,    69,  101, 21
III, South, Gupta,    11,  22,  21
III, East,  Haskins,  45,  41,  19
III, West,  LeMay,    35,  69,  20
III, West,  LeMay,    35,  69,  20
;;;;

proc format;
    value age_fmt 
        0 - 25  = '0-25'
        26 - 50 = '26-50'
		51 - 75 = '51-75'
		76 - high = 'Over 75';
run; 
proc sql;
   select unique put(age, age_fmt.) label = 'Group'  
         , count(age) label = 'Count' 
         , mean(age)  label = 'Mean'
		 , max(age)   label = 'Max'
		 , mean(age)  label = 'Mean'
		 
   from df
   group by put(age, age_fmt.);
   quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas_question.PNG" style="width: 404px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23367i7A007398F1C744C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas_question.PNG" alt="sas_question.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 01:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496802#M131490</guid>
      <dc:creator>rbetancourt</dc:creator>
      <dc:date>2018-09-19T01:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496803#M131491</link>
      <description>&lt;P&gt;Do you want to accomplish this in one pass of sql when there are no records that fall to the other age category with the existing set up?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am thinking , how about &lt;STRONG&gt;cntlin&lt;/STRONG&gt; your proc format and apply as you did&amp;nbsp; and create &lt;STRONG&gt;cntlout&lt;/STRONG&gt;&amp;nbsp; of the proc format full set and join the two in the same query ? Sorry if this doesn't make sense.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 02:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496803#M131491</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-19T02:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496804#M131492</link>
      <description>&lt;P&gt;Proc&amp;nbsp;SQL will &lt;STRONG&gt;not&lt;/STRONG&gt; create data where none exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to look at proc SUMMARY, and more specifically at its CLASSDATA option.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 02:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496804#M131492</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-19T02:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496805#M131493</link>
      <description>Thank you, novinosrin. I was hoping for a single SQL query with the present&lt;BR /&gt;approach. Your idea does make sense and I may need to consider it.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;Randy&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Sep 2018 03:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496805#M131493</guid>
      <dc:creator>rbetancourt</dc:creator>
      <dc:date>2018-09-19T03:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496811#M131498</link>
      <description>&lt;P&gt;I think &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;describes something like this&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data df;
infile cards dlm = ',';
length district $ 3
       sector $ 5
	   name $ 8;
input district $
      sector $
	  name $
	  pre
	  post
	  age;
list;
datalines; 
I,   North, Patton,   17,  27,  22
I,   South, Joyner,   13,  22,  19
I,   East,  Williams, 111, 121, 29
I,   West,  Jurat,    51,  55,  22
II,  North, Aden,     71,  70,  17
II,  South, Tanner,   113, 122, 32
II,  East,  Jenkins,  99,  99,  24
II,  West,  Milner,   15,  65,  22
III, North, Chang,    69,  101, 21
III, South, Gupta,    11,  22,  21
III, East,  Haskins,  45,  41,  19
III, West,  LeMay,    35,  69,  20
III, West,  LeMay,    35,  69,  20
;;;;

proc format cntlout=groups;
    value age_fmt 
        0 - 25  = '0-25'
        26 - 50 = '26-50'
		51 - 75 = '51-75'
		76 - high = 'Over 75';
run; 

proc sql;
select 
    a.label      label = 'Group',
    count(b.age) label = 'Count',
    mean(b.age)  label = 'Mean',
	max(b.age)   label = 'Max',
	mean(b.age)  label = 'Mean'
from 
    groups as a left join
    df as b on a.label = put(b.age, age_fmt.)
group by a.label;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 03:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496811#M131498</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-19T03:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496812#M131499</link>
      <description>&lt;P&gt;Yes boss&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;indeed sir. 10.30 pm at chicago , little too many pints with my mates to demo, but who better than &lt;STRONG&gt;Prodigygeniusstats aka PGstats. &lt;/STRONG&gt;Thanks again . Good night!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 03:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496812#M131499</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-19T03:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496813#M131500</link>
      <description>&lt;P&gt;Cheers! Good night!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 03:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496813#M131500</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-19T03:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL not displaying rows where all values are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496818#M131503</link>
      <description>&lt;P&gt;Spot on!&amp;nbsp; Thank you both.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 04:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-not-displaying-rows-where-all-values-are-missing/m-p/496818#M131503</guid>
      <dc:creator>rbetancourt</dc:creator>
      <dc:date>2018-09-19T04:06:22Z</dc:date>
    </item>
  </channel>
</rss>

