<?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 trouble in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77076#M22342</link>
    <description>where inactive_code not in ('D' 'M');&lt;BR /&gt;
&lt;BR /&gt;
OR&lt;BR /&gt;
&lt;BR /&gt;
where inactive_code ne 'D' and inactive_code ne 'M';&lt;BR /&gt;
&lt;BR /&gt;
Same thing.</description>
    <pubDate>Tue, 17 Mar 2009 16:14:15 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-17T16:14:15Z</dc:date>
    <item>
      <title>PROC SQL trouble</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77075#M22341</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am new to SAS (user for approx 5 months now, getting better every day!) and have encountered a snag in a query I am trying to execute.&lt;BR /&gt;
&lt;BR /&gt;
I am attempting to count the number of rows in a table but do &lt;B&gt;not&lt;/B&gt; want to include rows that include certain values of a particular column.  In my case, the column is 'inactive_code' and I want to make sure I am &lt;B&gt;not&lt;/B&gt; counting any records marked inactive due to the individual being deceased ('D') or moved ('M'). &lt;BR /&gt;
&lt;BR /&gt;
I have tried creating an SQL statement such as:&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select count (*)&lt;BR /&gt;
from table.test&lt;BR /&gt;
where pat_birth_date &amp;gt;='01JAN2003'd&lt;BR /&gt;
and pat_birth_date &amp;lt;='31AUG2008'd&lt;BR /&gt;
and inactive_code not in ('D', 'M');&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
but it does not return the correct values and I'm not sure why. &lt;BR /&gt;
&lt;BR /&gt;
I have also explored a function in Oracle called "NVL" but it apparently does not exist in PROC SQL as SAS responds that it does not recognize the function NVL.&lt;BR /&gt;
&lt;BR /&gt;
Attempting to manually do what NVL does (recode null variables, I think) is out of the question as the table I am querying is read-only for me and contains more than 1,000,000 records.&lt;BR /&gt;
&lt;BR /&gt;
The only way I have found to overcome the issue is to do three separate queries &lt;BR /&gt;
&lt;BR /&gt;
Query 1:   select all persons in the table that have inactive_code='D'&lt;BR /&gt;
Query 2:   select all persons in the table that have inactive_code='M'&lt;BR /&gt;
Query 3:   select all persons in the table (regardless of inactive_code)&lt;BR /&gt;
&lt;BR /&gt;
Then take the result from #3 and subtract 1+2...&lt;BR /&gt;
&lt;BR /&gt;
Any better way to do this?  Please be gentle, I am a novice at best...

Message was edited by: rocknroll_ghost</description>
      <pubDate>Tue, 17 Mar 2009 16:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77075#M22341</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-17T16:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL trouble</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77076#M22342</link>
      <description>where inactive_code not in ('D' 'M');&lt;BR /&gt;
&lt;BR /&gt;
OR&lt;BR /&gt;
&lt;BR /&gt;
where inactive_code ne 'D' and inactive_code ne 'M';&lt;BR /&gt;
&lt;BR /&gt;
Same thing.</description>
      <pubDate>Tue, 17 Mar 2009 16:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77076#M22342</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-17T16:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL trouble</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77077#M22343</link>
      <description>Sorry, for some reason my message was truncated--&lt;BR /&gt;
&lt;BR /&gt;
I have tried creating an SQL statement such as:&lt;BR /&gt;
&lt;B&gt;proc sql;&lt;BR /&gt;
select count (*) from table.test&lt;BR /&gt;
where pat_birth_date &amp;gt;='01JAN2003'd &lt;BR /&gt;
and pat_birth_date &amp;lt;='31AUG2008'd&lt;BR /&gt;
and inactive_code not in ('D', 'M');  &lt;BR /&gt;
quit;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
but it does not return the correct values and I'm not sure why. &lt;BR /&gt;
&lt;BR /&gt;
I have also explored a function in called "NVL" but it apparently does not exist in PROC SQL as SAS responds that it does not recognize the function NVL.&lt;BR /&gt;
&lt;BR /&gt;
Attempting to manually do what NVL does (recode null variables, I think) is out of the question as the table I am querying is read-only for me and contains more than 1,000,000 records.&lt;BR /&gt;
&lt;BR /&gt;
The only way I have found to overcome the issue is to do three separate queries &lt;BR /&gt;
&lt;BR /&gt;
Query 1:   select all persons in the table that have inactive_code='D'&lt;BR /&gt;
Query 2:   select all persons in the table that have inactive_code='M'&lt;BR /&gt;
Query 3:   select all persons in the table (regardless of inactive_code)&lt;BR /&gt;
&lt;BR /&gt;
Then take the result from #3 and subtract 1+2...&lt;BR /&gt;
&lt;BR /&gt;
Any better way to do this?  Please be gentle, I am a novice at best...

Message was edited by: rocknroll_ghost</description>
      <pubDate>Tue, 17 Mar 2009 16:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-trouble/m-p/77077#M22343</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-17T16:21:29Z</dc:date>
    </item>
  </channel>
</rss>

