<?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 CSV output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199023#M305624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a problem with output CSV data.&lt;/P&gt;&lt;P&gt;I have a file consist of Month/Year in Text format, for example 11/2007, 01/2003 ....ect.&lt;/P&gt;&lt;P&gt;when I use ODS csv to output the file, and then open in excel file,&amp;nbsp; the Month/Year values change from 11/2007 to 7-Nov, and 01/2003 changes to 3-Jan.&lt;/P&gt;&lt;P&gt;I wonder, is there a way to hold the original date value as is when I do ODS csv and looks the same when open in excel file.&lt;/P&gt;&lt;P&gt;Any idea would be appreciate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jul 2015 20:22:55 GMT</pubDate>
    <dc:creator>ursula</dc:creator>
    <dc:date>2015-07-08T20:22:55Z</dc:date>
    <item>
      <title>CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199023#M305624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a problem with output CSV data.&lt;/P&gt;&lt;P&gt;I have a file consist of Month/Year in Text format, for example 11/2007, 01/2003 ....ect.&lt;/P&gt;&lt;P&gt;when I use ODS csv to output the file, and then open in excel file,&amp;nbsp; the Month/Year values change from 11/2007 to 7-Nov, and 01/2003 changes to 3-Jan.&lt;/P&gt;&lt;P&gt;I wonder, is there a way to hold the original date value as is when I do ODS csv and looks the same when open in excel file.&lt;/P&gt;&lt;P&gt;Any idea would be appreciate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 20:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199023#M305624</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2015-07-08T20:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199024#M305625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem is the import in excel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 20:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199024#M305625</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2015-07-08T20:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199025#M305626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Peter.&lt;/P&gt;&lt;P&gt;I noticed, this is happened only if the date value is &lt;STRONG&gt;Month/year&lt;/STRONG&gt;, but it works fine if the date value is &lt;STRONG&gt;Month/Day/Year&lt;/STRONG&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 21:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199025#M305626</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2015-07-08T21:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199026#M305627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Ursula.&amp;nbsp;&amp;nbsp;&amp;nbsp; A couple of suggestions for possibilities.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1.&amp;nbsp; In Excel,&amp;nbsp; you could format the column&amp;nbsp;&amp;nbsp; via Format Cells, Custom,&amp;nbsp; mm/yyyy&lt;/P&gt;&lt;P&gt;2. When outputting to .csv from SAS, can you add a&amp;nbsp;&amp;nbsp; '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in front of each date record,&amp;nbsp; as in '01/2001.&amp;nbsp;&amp;nbsp; Should enable it to be viewed "as-is" in excel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 22:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199026#M305627</guid>
      <dc:creator>Eric_stats</dc:creator>
      <dc:date>2015-07-08T22:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199027#M305628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Eric for the suggestion.&lt;/P&gt;&lt;P&gt;The date record in my file actually is a text format, I have no idea why SAS read as numeric and interpret differently (wrong) when output as CSV file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 15:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199027#M305628</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2015-07-09T15:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199028#M305629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ursula,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As others have pointed out, this is for more likely an Excel problem than a SAS problem.&lt;/P&gt;&lt;P&gt;I suggest you look at the csv file in a plain text editor such as Notepad, not Excel, to see exactly what SAS is putting out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Excel (at least on my computer), if I enter 11/2007 in a cell, Excel automatically converts it to the date value for November 1, 2007, and displays Nov-07. As Eric@Stats suggests, you can format this with the custom format mm/yyyy so that it displays as 11/2007, but the internal value is still the date value for 11/1/2007, so if you later transfer the data to another program or another format, you may not get what you want. Essentially, Excel corrupts the data when it imports it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 16:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199028#M305629</guid>
      <dc:creator>Erico</dc:creator>
      <dc:date>2015-07-09T16:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199029#M305630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Erico and Eric.&lt;/P&gt;&lt;P&gt;I have 2 versions output the file into csv, the first output shows the date as 7-Nov, and the second output is Nov-07, I don't know why it came out different output with the same procedure.&lt;/P&gt;&lt;P&gt;I have tried to do custom format the date, it looks good for Nov-07 (format mm/yyyy -- 11/2007), but not the 7-Nov. I tried different format for 7-Nov, but it came out year as 2015.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 17:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199029#M305630</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2015-07-09T17:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199030#M305631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ursula,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When a CSV file is opened in Excel, Excel tries to guess the data type of each cell.&amp;nbsp; If the cell only contains numbers and some symbols (e.g., /) it will interpret it as a date.&amp;nbsp; This is regardless of the data type of your original SAS dataset.&amp;nbsp; Excel, however, does not support incomplete dates so it also tries to complete your dates, and sometimes it does it right and sometimes not.&amp;nbsp; On top of that, once the date is complete, Excel applies a format to the cell to display the date in a certain way.&amp;nbsp; You can't change how Excel treats dates, so depending on what your end goal is, I would suggest one of the following two options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1-In your SAS dataset, i.e., before exporting as CSV, add an apostrophe/single quote (') before the incomplete date, and then make sure this symbol appears in the CSV file.&amp;nbsp; When Excel opens the CSV file, it will interpret the cell as text and will show exactly what you want.&amp;nbsp; However, you won't be able to do calculations or sorting in Excel with this field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2-In your SAS dataset, complete the date (e.g., '03/2015' should be '03/01/2015' or '01-Mar-2015') and then convert it to a date field with the input function.&amp;nbsp; Excel will consistently import a complete date correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 18:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199030#M305631</guid>
      <dc:creator>DanielMK</dc:creator>
      <dc:date>2015-07-09T18:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: CSV output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199031#M305632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all of you who are responding to my question.&lt;/P&gt;&lt;P&gt;SAS communities would not be success without your support!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 19:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-output/m-p/199031#M305632</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2015-07-09T19:52:56Z</dc:date>
    </item>
  </channel>
</rss>

