<?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: SQL procedure in SAS - Left function in where statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83296#M23909</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nicnad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you read the documentation?&amp;nbsp; That is not what the LEFT and RIGHT functions do.&amp;nbsp; They are character string functions that just align the non-space part to the left or right in the string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the date filed is a text string, then you can get the first 4 characters as 2007 by&lt;/P&gt;&lt;P&gt;left(TXNS.DateOperation,4) =: "2007"&lt;/P&gt;&lt;P&gt;(not the "=:" operator).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is a SAS Date variable, then it would be&lt;/P&gt;&lt;P&gt;year(TXNS.DateOperation) = 2007&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like MontantOperation is numeric, in which case you need to either convert it to a string and pick off the last two characters (check RIGHT, LENGTH, and SUBSTR documentation for syntax; there are other ways possible (like reversing the string)).&amp;nbsp; Or by using some mathematical identities.&amp;nbsp; If montantoperation is an integer, this should work&lt;/P&gt;&lt;P&gt;floor(montantoperation/100) = montantoperation&lt;/P&gt;&lt;P&gt;to pick off numbers that are multiples of 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doc Muhlbaier&lt;/P&gt;&lt;P&gt;Duke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2013 15:50:00 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2013-03-20T15:50:00Z</dc:date>
    <item>
      <title>SQL procedure in SAS - Left function in where statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83295#M23908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following code where I want to display records where right(montantoperation,2) = 00 AND left(dateoperation,4) = "2007"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I write this properly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt; CREATE TABLE lctr.TXNS_2007_P_R AS SELECT TXNS.ApplProvenance,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.DateOperation,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.TypeCompte,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.NoTransit,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.NoCompte,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.NoGuichet,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.DateInscription,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.MontantOperation,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.CodeDevise,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.MontantBilletEspece,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.MontantMonnaie &lt;/P&gt;&lt;P&gt; FROM LCTR.TXNS AS TXNS&lt;/P&gt;&lt;P&gt; WHERE TXNS.TypeCompte = "1" AND right(TXNS.MontantOperation,2) = 00 AND left(TXNS.DateOperation,4) = "2007";&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 15:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83295#M23908</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-03-20T15:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: SQL procedure in SAS - Left function in where statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83296#M23909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nicnad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you read the documentation?&amp;nbsp; That is not what the LEFT and RIGHT functions do.&amp;nbsp; They are character string functions that just align the non-space part to the left or right in the string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the date filed is a text string, then you can get the first 4 characters as 2007 by&lt;/P&gt;&lt;P&gt;left(TXNS.DateOperation,4) =: "2007"&lt;/P&gt;&lt;P&gt;(not the "=:" operator).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is a SAS Date variable, then it would be&lt;/P&gt;&lt;P&gt;year(TXNS.DateOperation) = 2007&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like MontantOperation is numeric, in which case you need to either convert it to a string and pick off the last two characters (check RIGHT, LENGTH, and SUBSTR documentation for syntax; there are other ways possible (like reversing the string)).&amp;nbsp; Or by using some mathematical identities.&amp;nbsp; If montantoperation is an integer, this should work&lt;/P&gt;&lt;P&gt;floor(montantoperation/100) = montantoperation&lt;/P&gt;&lt;P&gt;to pick off numbers that are multiples of 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doc Muhlbaier&lt;/P&gt;&lt;P&gt;Duke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 15:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83296#M23909</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2013-03-20T15:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL procedure in SAS - Left function in where statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83297#M23910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Doc for your quick reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Substring and put worked well for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my working code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt; CREATE TABLE lctr.TXNS_2007_P_R AS SELECT TXNS.ApplProvenance,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.DateOperation,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.TypeCompte,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.NoTransit,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.NoCompte,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.NoGuichet,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.DateInscription,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.MontantOperation,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.CodeDevise,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.MontantBilletEspece,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TXNS.MontantMonnaie&lt;/P&gt;&lt;P&gt; FROM LCTR.TXNS AS TXNS&lt;/P&gt;&lt;P&gt; WHERE&amp;nbsp; substr(TXNS.DateOperation,1,4) = "2007"&lt;/P&gt;&lt;P&gt; AND TXNS.TypeCompte = "1"&lt;/P&gt;&lt;P&gt; AND substr(put(TXNS.MontantOperation,20.),length(put(TXNS.MontantOperation,20.))-2,2) = "00"&lt;/P&gt;&lt;P&gt;;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nicnad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-procedure-in-SAS-Left-function-in-where-statement/m-p/83297#M23910</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-03-20T18:00:45Z</dc:date>
    </item>
  </channel>
</rss>

