<?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: ods csv large number leads exponential values in excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83014#M288689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excel and SAS cannot accurately store a number beyond 15 digits, so if you want your data in Excel as a number, it will be somewhat incorrect, and exponential is the most appropriate way to show it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To demonstrate, if in Excel you type 123456789123456789, Excel will display it as 1.23457E+17. If you then explicitly display it with a "Number" format, it will come out as 123456789123456000, so you can see you've lost the digits after the 15th.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand, if you want it in Excel as character, which is the only way to present a representation of an 18 digit number, I think that your code is functioning correctly. Note that as soon as you try to execute numeric operations on it in Excel, however, it will revert to 15 digits of accuracy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Aug 2012 19:13:47 GMT</pubDate>
    <dc:creator>TomKari</dc:creator>
    <dc:date>2012-08-03T19:13:47Z</dc:date>
    <item>
      <title>ods csv large number leads exponential values in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83012#M288687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI, I have a column with large numbers defined as character datatype. When i write it to csv using an ODS statement or a proc export, the CSV file writes data properly, but when i view it in excel, it converts to exponential values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, i added double quotes with an = at the beginning, but due to some reason, a pair of double quotes gets appended in the CSV file. This time, the excel view is OK but the CSV data is not as expected. Any inputs is highly appreciated. I need the data to be accurate in CSV at the same time, excel should present it accurately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I prefer not to generate an xls file as the number of records run into millions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; source;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; x &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: teal; background: none repeat scroll 0% 0% white;"&gt;$22.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% #ffffc0;"&gt;123456789123456789&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% #ffffc0;"&gt;987654321123456789&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; csvdata;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; source;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;new_x&amp;nbsp; = &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background: none repeat scroll 0% 0% white;"&gt;'="'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;||trim(x)||&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background: none repeat scroll 0% 0% white;"&gt;'"'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;--first method --&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;export&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; = csvdata&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;outfile&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background: none repeat scroll 0% 0% white;"&gt;'/users/test/procexport.csv'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;dbms&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background: none repeat scroll 0% 0% white;"&gt;'csv'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;--second method--&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;ODS&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;CSV&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;FILE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background: none repeat scroll 0% 0% white;"&gt;'/users/test/ods.csv'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;PROC&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;PRINT&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;=csvdata; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;RUN&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;ODS&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;CSV&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;CLOSE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;output file ods.csv when viewed a notepad&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;"Obs","x","new_x"&lt;/P&gt;&lt;P&gt;"1",123456789123456789,"=""123456789123456789"""&lt;/P&gt;&lt;P&gt;"2",987654321123456789,"=""987654321123456789"""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We see that additional pair of double quotes gets appended at the end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Results when viewed in excel&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 283px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" width="64"&gt;&lt;STRONG&gt;Obs&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" style="border-left: medium none;" width="84"&gt;&lt;STRONG&gt;x&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" style="border-left: medium none;" width="135"&gt;&lt;STRONG&gt;new_x&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="20" style="border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: medium none; border-left: medium none;"&gt;1.23457E+17&lt;/TD&gt;&lt;TD class="xl63" style="border-top: medium none; border-left: medium none;"&gt;123456789123456789&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="20" style="border-top: medium none;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: medium none; border-left: medium none;"&gt;9.87654E+17&lt;/TD&gt;&lt;TD class="xl63" style="border-top: medium none; border-left: medium none;"&gt;987654321123456789&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 06:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83012#M288687</guid>
      <dc:creator>khs_chaitanya</dc:creator>
      <dc:date>2012-08-03T06:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: ods csv large number leads exponential values in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83013#M288688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make the cell wider in Excel. It is not a SAS behavior causing this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 14:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83013#M288688</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-08-03T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: ods csv large number leads exponential values in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83014#M288689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excel and SAS cannot accurately store a number beyond 15 digits, so if you want your data in Excel as a number, it will be somewhat incorrect, and exponential is the most appropriate way to show it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To demonstrate, if in Excel you type 123456789123456789, Excel will display it as 1.23457E+17. If you then explicitly display it with a "Number" format, it will come out as 123456789123456000, so you can see you've lost the digits after the 15th.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand, if you want it in Excel as character, which is the only way to present a representation of an 18 digit number, I think that your code is functioning correctly. Note that as soon as you try to execute numeric operations on it in Excel, however, it will revert to 15 digits of accuracy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 19:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ods-csv-large-number-leads-exponential-values-in-excel/m-p/83014#M288689</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-08-03T19:13:47Z</dc:date>
    </item>
  </channel>
</rss>

