<?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 PROC SQL CAST for converting decimals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-CAST-for-converting-decimals/m-p/571933#M161362</link>
    <description>&lt;P&gt;Hi I'm just wondering how to convert this SQL statement into PROC SQL. I'm using SAS version 7.15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;case&lt;BR /&gt;&amp;nbsp;when pdi.Value2 is not null&lt;BR /&gt;&amp;nbsp;then CONCAT(CAST(pdi.Value as decimal(18,3)), '-', CAST(pdi.Value2 as decimal(18,3)))&lt;BR /&gt;&amp;nbsp;else CONVERT(varchar(20), pdi.Value)&lt;BR /&gt;end as PeerDataValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far and it doesn't seem to work;&lt;/P&gt;&lt;P&gt;any help is appreciated&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case 
 when pdi.Value2 is not null
 then CAT((put(pdi.Value,18,3)), '-', (put(pdi.Value2,18,3)))
 else put(pdi.Value, $20) as pdi.Value
end as PeerDataValue,&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Jul 2019 02:10:07 GMT</pubDate>
    <dc:creator>kenjichan1212</dc:creator>
    <dc:date>2019-07-09T02:10:07Z</dc:date>
    <item>
      <title>PROC SQL CAST for converting decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-CAST-for-converting-decimals/m-p/571933#M161362</link>
      <description>&lt;P&gt;Hi I'm just wondering how to convert this SQL statement into PROC SQL. I'm using SAS version 7.15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;case&lt;BR /&gt;&amp;nbsp;when pdi.Value2 is not null&lt;BR /&gt;&amp;nbsp;then CONCAT(CAST(pdi.Value as decimal(18,3)), '-', CAST(pdi.Value2 as decimal(18,3)))&lt;BR /&gt;&amp;nbsp;else CONVERT(varchar(20), pdi.Value)&lt;BR /&gt;end as PeerDataValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far and it doesn't seem to work;&lt;/P&gt;&lt;P&gt;any help is appreciated&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case 
 when pdi.Value2 is not null
 then CAT((put(pdi.Value,18,3)), '-', (put(pdi.Value2,18,3)))
 else put(pdi.Value, $20) as pdi.Value
end as PeerDataValue,&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 02:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-CAST-for-converting-decimals/m-p/571933#M161362</guid>
      <dc:creator>kenjichan1212</dc:creator>
      <dc:date>2019-07-09T02:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL CAST for converting decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-CAST-for-converting-decimals/m-p/571938#M161366</link>
      <description>&lt;P&gt;Something like this should work. Not sure how many digits you want but SAS can only accurately store 15 or 16 (I've specified 15 digits with 3 decimal places). Value and Value2 must be numeric for this to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CATS(put(pdi.Value,15.3), '-', put(pdi.Value2,15.3))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 02:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-CAST-for-converting-decimals/m-p/571938#M161366</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-07-09T02:08:38Z</dc:date>
    </item>
  </channel>
</rss>

