<?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: order by and outer union corr in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174927#M44912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are mostly there.&lt;/P&gt;&lt;P&gt;SAS interprets non-missing values other than 0 as TRUE.&lt;/P&gt;&lt;P&gt;What you also need to know is that when it evaluates a logic expression, such as (dart_new=1), it will return 1 when true and 0 otherwise.&lt;/P&gt;&lt;P&gt;So if you code SUM( (dart_new=1) ) in SQL statement then you are asking to sum the results of that logic expression. So basically you are counting the number of rows where dart_new=1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Apr 2014 16:26:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2014-04-10T16:26:20Z</dc:date>
    <item>
      <title>proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174921#M44906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An error is being generated in between the order by and outer union corr lines.&lt;/P&gt;&lt;P&gt;I'm trying to sort dart_tot in descending order and then have 'Total' dart_tot appear on the last row.&lt;/P&gt;&lt;P&gt;Does anyone know how to fix this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; CREATE TABLE loc_sum as&lt;/P&gt;&lt;P&gt; SELECT loc_grp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(dart_new) as dart_tot&lt;/P&gt;&lt;P&gt; FROM new_file1&lt;/P&gt;&lt;P&gt; where dart_new=1&lt;/P&gt;&lt;P&gt; group by loc_grp&lt;/P&gt;&lt;P&gt; order by dart_tot desc&lt;/P&gt;&lt;P&gt; outer union corr&lt;/P&gt;&lt;P&gt; select 'Total' as loc_grp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(dart_new) as dart_tot&lt;/P&gt;&lt;P&gt; from new_file1&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 00:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174921#M44906</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2014-04-10T00:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174922#M44907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ORDER BY clause must be last.&lt;/P&gt;&lt;P&gt;If you want to order the detail rows separately from the total row then you should add another grouping variable that you can use to order.&lt;/P&gt;&lt;P&gt;Also did you mean to only use the WHERE clause on the detail lines?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt; create&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; loc_sum &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sort_grp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , loc_grp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , sum(dart_new) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dart_tot&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; new_file1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dart_new=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; loc_grp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;outer&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;union&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; corr&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sort_grp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'total'&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; loc_grp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , sum(dart_new) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dart_tot&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; new_file1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sort_grp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dart_tot &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;desc&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 00:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174922#M44907</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-04-10T00:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174923#M44908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or, since &lt;STRONG&gt;OUTER UNION CORR&lt;/STRONG&gt; keeps non-matching columns, you may let &lt;STRONG&gt;loc_grp&lt;/STRONG&gt; be missing on the total line and put the 'total' label in a new sorting variable, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table loc_sum as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;loc_grp,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;sum(dart_new) as dart_tot&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;from new_file1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where dart_new=1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by loc_grp&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;outer union corr&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;'total' as sort_grp,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(dart_new) as dart_tot&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from new_file1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* &lt;EM&gt; where dart_new=1&lt;/EM&gt; */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;order by &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;sort_grp,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dart_tot desc&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: If you want to see the cases where&lt;STRONG&gt; dart_tot=0&lt;/STRONG&gt;, you should use &lt;STRONG&gt;sum(dart_new=1) as dart_tot&lt;/STRONG&gt; and remove the &lt;STRONG&gt;where&lt;/STRONG&gt; clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 03:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174923#M44908</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-04-10T03:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174924#M44909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PG STATS,&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #333333; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt; &lt;/STRONG&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 9pt;"&gt;I have never seen the convention function(argument &lt;STRONG&gt;equals&lt;/STRONG&gt; value)&amp;nbsp; before.&amp;nbsp; What is the effect of&amp;nbsp; "sum&lt;/SPAN&gt;(dart_new &lt;STRONG&gt;equals&lt;/STRONG&gt; 1)" on each row of the table produced by the sql?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 12:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174924#M44909</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-04-10T12:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174925#M44910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SAS-SQL expressions, the result of a comparison operator is 1 (=TRUE) or 0 (=FALSE). Thus &lt;STRONG&gt;sum(dart_new=1)&lt;/STRONG&gt; counts the number of cases where dart_new = 1. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 14:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174925#M44910</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-04-10T14:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174926#M44911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PG,&lt;/P&gt;&lt;P&gt;Please forgive my ignorance.&amp;nbsp; I am trying to understand a neat concept.&amp;nbsp; Your note and what the SAS book says are confusing me.&amp;nbsp; I understand&amp;nbsp; that any posiitve number greater than zero is "true" and zero and negative numbers are "false".&amp;nbsp; I do not understand how "sum(dart_new=1)" is equivalent to "where dart_new=1".&amp;nbsp; If I understand the SQL code above dart_new is a variable containing a numeric value of 1 or zero and the sum(dart_new) statement in the unioned query will sum all the non-missing values of dart_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: If you want to see the cases where&lt;STRONG&gt; dart_tot=0&lt;/STRONG&gt;, you should use &lt;STRONG&gt;sum(dart_new=1) as dart_tot&lt;/STRONG&gt; and remove the &lt;STRONG&gt;where&lt;/STRONG&gt; clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM Function (SAS 9.3 Functions and Call Routines Reference Volume 2. Page 877&lt;/P&gt;&lt;P&gt;"Returns the sum of the nonmissing arguments".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174926#M44911</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-04-10T15:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: order by and outer union corr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174927#M44912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are mostly there.&lt;/P&gt;&lt;P&gt;SAS interprets non-missing values other than 0 as TRUE.&lt;/P&gt;&lt;P&gt;What you also need to know is that when it evaluates a logic expression, such as (dart_new=1), it will return 1 when true and 0 otherwise.&lt;/P&gt;&lt;P&gt;So if you code SUM( (dart_new=1) ) in SQL statement then you are asking to sum the results of that logic expression. So basically you are counting the number of rows where dart_new=1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 16:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-order-by-and-outer-union-corr/m-p/174927#M44912</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-04-10T16:26:20Z</dc:date>
    </item>
  </channel>
</rss>

