<?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 long characters into numerics with decimals in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148629#M2497</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need to sort numerically and that's all, could you do it with two variables, one whole, one part and then use both in the sort:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; attrib ct_claim_trans_id format=$200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ct_claim_trans_id="842825";output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ct_claim_trans_id="228390.2086";output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ct_claim_trans_id="20111212111209.5639";output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; attrib ct_claim_trans_no format=best19.5 inter format=best19.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if index(ct_claim_trans_id,".")&amp;gt;0 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ct_claim_trans_no=input(substr(ct_claim_trans_id,1,index(ct_claim_trans_id,".")-1),best19.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inter=input(substr(ct_claim_trans_id,index(ct_claim_trans_id,".")+1),best19.)/10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ct_claim_trans_no=input(strip(ct_claim_trans_id),best.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort...&lt;/P&gt;&lt;P&gt; by ct_claim_trans_no inter;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Mar 2014 10:38:24 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-03-19T10:38:24Z</dc:date>
    <item>
      <title>Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148626#M2494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have trouble converting particularly long character values such as "20111019111006.18993" correctly into numeric with up to five decimals. The latest I've tried is "input(ct_CLAIM_TRANS_ID, d19.5)", with informat 19.5 and format 19.5. Here's what that ends up looking like. I want the right-hand column values to be equal to the left-hand column values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="5756" alt="Skjermbilde.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/5756_Skjermbilde.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please offer some advice on this? Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 09:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148626#M2494</guid>
      <dc:creator>ENM</dc:creator>
      <dc:date>2014-03-19T09:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148627#M2495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are several discussions on the forum regarding long numerical data.&lt;/P&gt;&lt;P&gt;Since you are not going to make any calculations (it's an id, right?), why can't you keep it as char?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 09:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148627#M2495</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-03-19T09:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148628#M2496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I see, thanks. Each row represents a payment, and is associated with a policy ID. There's a field which calculates how much is paid &lt;SPAN style="text-decoration: underline;"&gt;so far&lt;/SPAN&gt; (it takes the payment amount from the previous row, and adds the payment amount from the current row), per policy ID. In order for this amount to be set in the correct order per policy, the data must be sorted based on transaction number. If the transaction number is character, then the number 94 would come after 124578. Making the transaction ID numeric is only needed for the UWC which is used to calculate how much is paid so far; it remains a character for all other purposes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 09:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148628#M2496</guid>
      <dc:creator>ENM</dc:creator>
      <dc:date>2014-03-19T09:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148629#M2497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need to sort numerically and that's all, could you do it with two variables, one whole, one part and then use both in the sort:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; attrib ct_claim_trans_id format=$200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ct_claim_trans_id="842825";output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ct_claim_trans_id="228390.2086";output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ct_claim_trans_id="20111212111209.5639";output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; attrib ct_claim_trans_no format=best19.5 inter format=best19.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if index(ct_claim_trans_id,".")&amp;gt;0 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ct_claim_trans_no=input(substr(ct_claim_trans_id,1,index(ct_claim_trans_id,".")-1),best19.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inter=input(substr(ct_claim_trans_id,index(ct_claim_trans_id,".")+1),best19.)/10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ct_claim_trans_no=input(strip(ct_claim_trans_id),best.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort...&lt;/P&gt;&lt;P&gt; by ct_claim_trans_no inter;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 10:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148629#M2497</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-19T10:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148630#M2498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is to select a length, that will be longer than all of your "integer" parts of the transaction number, and then pad them all to the left with leading zeroes. This will avoid the risks associated with converting it to numeric, and the sort will work correctly. So the IDs would become:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;00000000842825&lt;/P&gt;&lt;P&gt;00000000228390.2086&lt;/P&gt;&lt;P&gt;20111212111209.5639&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 14:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148630#M2498</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2014-03-19T14:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148631#M2499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only if you left align the digits in the character variable.&amp;nbsp; Pad them on the left with zeros or spaces.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 14:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148631#M2499</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-19T14:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148632#M2500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried the SORTSEQ option in proc sort using NUMERIC_COLLATION=ON? It might avoid the whole issue. It seems to work with this example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data junk;&lt;/P&gt;&lt;P&gt;x = '111111111111111111111.2222222222';output;&lt;/P&gt;&lt;P&gt;x = '2222';output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort sortseq=linguistic (NUMERIC_COLLATION=on);by x;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 17:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148632#M2500</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-03-19T17:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting long characters into numerics with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148633#M2501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very nice! I hadn't seen this one before!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 18:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-long-characters-into-numerics-with-decimals/m-p/148633#M2501</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2014-03-19T18:40:16Z</dc:date>
    </item>
  </channel>
</rss>

