<?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 Help in my sql code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665119#M198806</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help in my sql code.&amp;nbsp; Some one helped the code. It worked but i have one more condition that i need to add.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting output i need for all&amp;nbsp; &amp;nbsp;where &lt;FONT color="#FF6600"&gt;"var"&amp;nbsp; &amp;nbsp;in&amp;nbsp; a,b,c,d,e,f.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But &lt;FONT color="#FF6600"&gt;var=g&amp;nbsp;&lt;/FONT&gt; &amp;nbsp;where i included a&amp;nbsp; &amp;nbsp; &amp;nbsp; "&lt;CODE class=" language-sas"&gt;&lt;FONT color="#FF6600"&gt;when value lt 1 then 0"&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Please&amp;nbsp;suggest.&amp;nbsp;Thank&amp;nbsp;you&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Output&amp;nbsp;needed&amp;nbsp;for&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;=g&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;var&amp;nbsp;value&amp;nbsp;prec&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.5&amp;nbsp;&amp;nbsp;0&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;&amp;nbsp;0&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;output&amp;nbsp;getting&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;var&amp;nbsp;value&amp;nbsp;prec&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.5&amp;nbsp;&amp;nbsp;0&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var $ value;
datalines;
a 100.01
a 110.003
a 100
b 1.1
b 2
c 5.000002
c 6.01
c 4
d 2
d 5
d 1120
e .
e 100
e 10.02
f .
f 10
g 0.5
g 10
;
proc sql;
create table want as
select 
    *,
    case when value =. then .
         &lt;FONT color="#FF6600"&gt;when value lt 1 then 0&lt;/FONT&gt; 
        else max(lengthn(scan(put(value, best32.), 2, "."))) end as prec
from have
group by var;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Jun 2020 18:50:11 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2020-06-25T18:50:11Z</dc:date>
    <item>
      <title>Help in my sql code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665119#M198806</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help in my sql code.&amp;nbsp; Some one helped the code. It worked but i have one more condition that i need to add.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting output i need for all&amp;nbsp; &amp;nbsp;where &lt;FONT color="#FF6600"&gt;"var"&amp;nbsp; &amp;nbsp;in&amp;nbsp; a,b,c,d,e,f.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But &lt;FONT color="#FF6600"&gt;var=g&amp;nbsp;&lt;/FONT&gt; &amp;nbsp;where i included a&amp;nbsp; &amp;nbsp; &amp;nbsp; "&lt;CODE class=" language-sas"&gt;&lt;FONT color="#FF6600"&gt;when value lt 1 then 0"&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Please&amp;nbsp;suggest.&amp;nbsp;Thank&amp;nbsp;you&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Output&amp;nbsp;needed&amp;nbsp;for&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;=g&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;var&amp;nbsp;value&amp;nbsp;prec&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.5&amp;nbsp;&amp;nbsp;0&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;&amp;nbsp;0&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;output&amp;nbsp;getting&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;var&amp;nbsp;value&amp;nbsp;prec&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.5&amp;nbsp;&amp;nbsp;0&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var $ value;
datalines;
a 100.01
a 110.003
a 100
b 1.1
b 2
c 5.000002
c 6.01
c 4
d 2
d 5
d 1120
e .
e 100
e 10.02
f .
f 10
g 0.5
g 10
;
proc sql;
create table want as
select 
    *,
    case when value =. then .
         &lt;FONT color="#FF6600"&gt;when value lt 1 then 0&lt;/FONT&gt; 
        else max(lengthn(scan(put(value, best32.), 2, "."))) end as prec
from have
group by var;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jun 2020 18:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665119#M198806</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2020-06-25T18:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help in my sql code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665130#M198812</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;maybe this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select 
    var,
    value format best32.,
    case when value = . then .
         when value &amp;lt; 1 then 0 
         else max(case when value &amp;lt; 1 then 0
             else lengthn(scan(put(value, best32.), 2, ".")) end) 
         end as prec        
from have
group by var;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 19:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665130#M198812</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-06-25T19:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help in my sql code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665132#M198813</link>
      <description>&lt;P&gt;What exactly are you trying to do with this code? Are you sure your results for a, b, c, d, e, and f are what you expect?&lt;/P&gt;
&lt;P&gt;Is&amp;nbsp;&lt;STRONG&gt;prec&amp;nbsp;&lt;/STRONG&gt;supposed to be the precision of&amp;nbsp;&lt;STRONG&gt;value&lt;/STRONG&gt;? (If so, how do you get&amp;nbsp;&lt;STRONG&gt;prec&amp;nbsp;&lt;/STRONG&gt;= 6 for&amp;nbsp;&lt;STRONG&gt;value&amp;nbsp;&lt;/STRONG&gt;= 4?)&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 19:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-sql-code/m-p/665132#M198813</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-25T19:29:55Z</dc:date>
    </item>
  </channel>
</rss>

