<?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: Missing digits when copying a number to another column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855475#M338100</link>
    <description>&lt;P&gt;Looks like you already defined NEW_CPFN in the source dataset and the length defined for it is not long enough to store an 18 digit string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check this example:&lt;/P&gt;
&lt;PRE&gt;2892   data test;
2893     length number1 number2 8 string1 string2 $8 string3 $18;
2894     number1=1234567890123 ;
2895     number2=put(number1,18.);
2896     string1=put(number1,18.);
2897     string2=put(number1,18.-L);
2898     string3=put(number1,18.);
2899     format number: best18. string: $quote. ;
2900     put (_all_) (=/);
2901   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      2895:11

number1=1234567890123
number2=1234567890123
string1="     123"
string2="12345678"
string3="     1234567890123"
&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 Jan 2023 20:53:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-01-24T20:53:14Z</dc:date>
    <item>
      <title>Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855441#M338088</link>
      <description>&lt;P&gt;Hi, I am trying to copy a number from one column to another&lt;/P&gt;&lt;PRE&gt;data MS_MAIN_INPUT;
set MS_MAIN_INPUT_0;
retain new_CPFN;
if MARCA="A" then new_CPFN = CPFN;
if MARCA="N" then new_CPFN = CPFN_old;
run;&lt;/PRE&gt;&lt;P&gt;But it seems that the number loses some digits when doing the copy.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_0-1674588497528.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79747i9556618AE4F84A24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_0-1674588497528.png" alt="sebastiaam_0-1674588497528.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I export to CSV this table I see that the number is different&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_1-1674588587188.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79748i4F180DE57BDADACA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_1-1674588587188.png" alt="sebastiaam_1-1674588587188.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_2-1674588607298.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79749i57C85164211ED822/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_2-1674588607298.png" alt="sebastiaam_2-1674588607298.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How can I keep all the digits?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855441#M338088</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2023-01-24T19:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855444#M338089</link>
      <description>&lt;P&gt;SAS cannot represent exactly numbers that are 15 digits long (or longer), and so "rounding" occurs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numbers such as this should be character strings, and then the problem goes away.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855444#M338089</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-24T19:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855446#M338090</link>
      <description>&lt;P&gt;Assign a proper format (e.g. 32.).&lt;/P&gt;
&lt;P&gt;But your numbers with 16 digits are right on the verge of numeric precision (SAS stores numbers in 8 byte real).&lt;/P&gt;
&lt;P&gt;If these are in fact codes and not numbers, they should be stored as character when the data is read into SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855446#M338090</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-24T19:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855452#M338091</link>
      <description>&lt;P&gt;Are you doing arithmetic with the variables CPFN or new_CPFN? If not, I would go back to the initial read data into SAS step and make sure that CPFN is character.&lt;/P&gt;
&lt;P&gt;BTW, if the CPFN or other variable had leading zeroes then the read as numeric lost those. Which means that values in the original source such as "000123" and&amp;nbsp; "0000000000123" would both now be numeric 123 and likely wrong for some purposes.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855452#M338091</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-24T19:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855470#M338097</link>
      <description>&lt;P&gt;Thank You!&lt;/P&gt;&lt;P&gt;I am trying to change into character but I don't get the whole number. How can I do it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_0-1674592900073.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79752iD715EA1A20AD859F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_0-1674592900073.png" alt="sebastiaam_0-1674592900073.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;data want;
set tables;
retain new_CPFN;
if MARCA="A" then new_CPFN = put(CPFN, 18.);
if MARCA="N" then new_CPFN = put(CPFN_old, 18.);
run;&lt;/PRE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 20:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855470#M338097</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2023-01-24T20:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855475#M338100</link>
      <description>&lt;P&gt;Looks like you already defined NEW_CPFN in the source dataset and the length defined for it is not long enough to store an 18 digit string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check this example:&lt;/P&gt;
&lt;PRE&gt;2892   data test;
2893     length number1 number2 8 string1 string2 $8 string3 $18;
2894     number1=1234567890123 ;
2895     number2=put(number1,18.);
2896     string1=put(number1,18.);
2897     string2=put(number1,18.-L);
2898     string3=put(number1,18.);
2899     format number: best18. string: $quote. ;
2900     put (_all_) (=/);
2901   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      2895:11

number1=1234567890123
number2=1234567890123
string1="     123"
string2="12345678"
string3="     1234567890123"
&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2023 20:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855475#M338100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-24T20:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Missing digits when copying a number to another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855477#M338101</link>
      <description>&lt;P&gt;Thanks! That was it!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 21:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-digits-when-copying-a-number-to-another-column/m-p/855477#M338101</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2023-01-24T21:31:44Z</dc:date>
    </item>
  </channel>
</rss>

