<?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: Converting SQL Code to SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375608#M90069</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes, you can use the put and input functions to decode a format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select...&lt;/P&gt;&lt;P&gt;put(a.sex,$Sex.) as Gender&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2017 10:21:20 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2017-07-13T10:21:20Z</dc:date>
    <item>
      <title>Converting SQL Code to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375603#M90068</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to convert the below code to work in SAS? Specifically I am looking for alternative options for "decode", "sign", "to_number" &amp;amp;&amp;nbsp;"to_char" functions used in the below code. Any help on this is highly appreciated.&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.var1,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;count(c.var2) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var2 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma20.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;sum(c.var3) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var3 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma20.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;sum(a.var4) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var4 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma20.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;decode( c.var5,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,a.var6,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;decode( sign(to_number( to_char( d.var7,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'yyyymmdd'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) )),&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;500&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;a.var6))&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; db.table1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a, db.table2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b, db.table3 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c, db.table4 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; d&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.key1 = d.key1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b.key2 = a.key2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.key3 = c.key3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b.date &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;is&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; null&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.var1,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;decode( c.var5,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,a.var6,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;decode( sign(to_number( to_char( d.var7,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'yyyymmdd'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) )),&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;500&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;a.var6))&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;order&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;asc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 10:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375603#M90068</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-07-13T10:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting SQL Code to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375608#M90069</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes, you can use the put and input functions to decode a format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select...&lt;/P&gt;&lt;P&gt;put(a.sex,$Sex.) as Gender&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 10:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375608#M90069</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-07-13T10:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Converting SQL Code to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375611#M90070</link>
      <description>&lt;P&gt;Yes:&lt;/P&gt;
&lt;P&gt;decode - you can replace this in a couple of ways, formats, or case when &amp;lt;&amp;gt; then &amp;lt;&amp;gt; else &amp;lt;&amp;gt; end statements.&lt;/P&gt;
&lt;P&gt;to_number - you can replace this with input(&amp;lt;&amp;gt;,best.)&lt;/P&gt;
&lt;P&gt;to_char - you can replace with put(&amp;lt;&amp;gt;,best&lt;/P&gt;
&lt;P&gt;sign - again number of different ways but case when &amp;lt;&amp;gt; &amp;lt; 0 then -1 when &amp;lt;&amp;gt; =0 then 0 else 1 end&lt;/P&gt;
&lt;P&gt;(note &amp;lt;&amp;gt; is your logic or variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, I dont think that SQL code will wok as you expect as you are aggregating (sum,count) by a group, but you also have where clauses and variables which are not aggregated. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 10:41:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-SQL-Code-to-SAS/m-p/375611#M90070</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-13T10:41:16Z</dc:date>
    </item>
  </channel>
</rss>

