<?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 in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643441#M24008</link>
    <description>&lt;P&gt;Usually I see that error when I run code like in your original post. You opened the ODS destination, but never wrote anything to it, and then closed it. SAS does not make a working XLSX file in that case.&amp;nbsp; Not sure what a working XLSX file with no sheets in it would look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have an encoding issue? What encoding is your SAS session using? Does any of your character data using non-7 bit ASCII codes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are your Excel users getting access to the XLSX file? Do they have to move them via a file transfer tool like FTP? If so make sure to move them as binary and not as text.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Apr 2020 00:25:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-28T00:25:09Z</dc:date>
    <item>
      <title>ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/292107#M16636</link>
      <description>&lt;P&gt;I am running below program it is crating csv file but it is empty, i able to see output in EG(output dataset).&lt;/P&gt;&lt;P&gt;ods CSVALL file="/home/xxx/myoutput1.csv";&lt;/P&gt;&lt;P&gt;data sapmle1;&lt;BR /&gt;set sample;&lt;BR /&gt;/*date= MONTH(birth);*/&lt;BR /&gt;today=date();&lt;BR /&gt;/*monthoftoday=MONTH(today);*/&lt;BR /&gt;totledays=(today-birth);&lt;BR /&gt;if totledays&amp;lt;=180;&lt;BR /&gt;format today ddmmyy.;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;ods CSVALL close;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 09:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/292107#M16636</guid>
      <dc:creator>Sharukh</dc:creator>
      <dc:date>2016-08-17T09:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/292112#M16637</link>
      <description>&lt;P&gt;You have no output creating procedure. &amp;nbsp;Datasteps create datasets, they don't create output. &amp;nbsp;You shoul use proc print or report or something simliar to create output:&lt;/P&gt;
&lt;PRE&gt;ods csvall file="c:\myoutput1.csv";
proc print data=sashelp.class;
run;
ods csvall close;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2016 10:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/292112#M16637</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-17T10:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643427#M23999</link>
      <description>&lt;P&gt;Is there a way to produce the same output as the %ds2csv macro using ODS? I am looking for double quotes around values and only the %ds2csv SAS macro seems to do it. Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 22:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643427#M23999</guid>
      <dc:creator>xd9813</dc:creator>
      <dc:date>2020-04-27T22:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643428#M24000</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183337"&gt;@xd9813&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there a way to produce the same output as the %ds2csv macro using ODS? I am looking for double quotes around values and only the %ds2csv SAS macro seems to do it. Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why do you want extra bytes in your CSV file?&lt;/P&gt;
&lt;P&gt;Is there some specific program/system that you are transferring the data to that required the unneeded quotes?&lt;/P&gt;
&lt;P&gt;Can you please name it? Public shaming is a good way to put pressure on them to make their systems more robust.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to write a CSV file then there is no need for a PROC or ODS.&amp;nbsp; A simple data step will do it.&amp;nbsp; And you can have full control over how the file is written.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 22:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643428#M24000</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-27T22:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643430#M24001</link>
      <description>&lt;P&gt;Some users in the org open these CSV files in MS Excel. As a result, the fields that have leading zeros or card numbers get truncated. Additionally, importing the&amp;nbsp;same dataset to Excel has caused file corruption with that&amp;nbsp;Excel needs to repair message while opening the workbook.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;am looking for a way to replicate db2csv which is a SAS system macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank&amp;nbsp;you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 22:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643430#M24001</guid>
      <dc:creator>xd9813</dc:creator>
      <dc:date>2020-04-27T22:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643433#M24002</link>
      <description>&lt;P&gt;Quotes around the values will not slow down Excels ability to mess up the import AT ALL.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643433#M24002</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-27T23:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643434#M24003</link>
      <description>Quotes work, I tested. Excel does not truncate data if surrounded by quotes. Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643434#M24003</guid>
      <dc:creator>xd9813</dc:creator>
      <dc:date>2020-04-27T23:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643435#M24004</link>
      <description>&lt;P&gt;If you need to use the data in Excel then generate XLSX files.&amp;nbsp; You can use ODS EXCEL or the XLSX libname engine.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643435#M24004</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-27T23:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643437#M24005</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183337"&gt;@xd9813&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Quotes work, I tested. Excel does not truncate data if surrounded by quotes. Thanks&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are careful HOW you open the file then you can prevent Excel from interpreting strings as numbers or dates, whether the quotes are there are not has never made any difference in my experience.&amp;nbsp; I have never heard of Excel truncating any values, but it did use to have a problem with writing long strings in a single cell, but that was decades ago.&amp;nbsp; Does you data have long strings?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is simple SAS program to dump a dataset to a CSV file with every value in quotes, like the %ds2csv() macro does.&lt;/P&gt;
&lt;P&gt;First let's set up an example dataset and target filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  set sashelp.class(obs=3);
run;
filename csv3 temp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now here is the code.&amp;nbsp; One PROC and two data steps.&amp;nbsp; The PROC is to get the names.&amp;nbsp; If you don't need the header row then just use the last data step without the MOD option on the FILE statement (unless you want to append to an existing file).&amp;nbsp; The tilde modifier on the PUT statement is what is adding the quotes.&amp;nbsp; If you remove that then the DSD option will only add the quotes where they are NEEDED.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test1(obs=0) out=names ;
 var _all_;
run;
data _null_;
  file csv3 dsd ;
  set names end=eof;
  put _name_ ~ @ ;
  if eof then put;
run;
data _null_;
  file csv3 dsd mod;
  set test1;
  put (_all_) (~);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's take a look at the results:&lt;/P&gt;
&lt;PRE&gt;157  data _null_;
158   infile csv3;
159   input;
160   put _infile_;
161  run;

NOTE: The infile CSV3 is:
      Filename=.../#LN00050,
      Owner Name=...,Group Name=...,
      Access Permission=-rw-rw-r--,
      Last Modified=27Apr2020:19:06:53,
      File Size (bytes)=128

"Name","Sex","Age","Height","Weight"
"Alfred","M","14","69","112.5"
"Alice","F","13","56.5","84"
"Barbara","F","13","65.3","98"
NOTE: 4 records were read from the infile CSV3.
      The minimum record length was 28.
      The maximum record length was 36.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643437#M24005</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-27T23:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643438#M24006</link>
      <description>&lt;P&gt;I tried ODS Excel with PROC Print. End user gets this error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xd9813_0-1588029664705.png" style="width: 777px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38807iAD69CCE199AB9706/image-dimensions/777x101?v=v2" width="777" height="101" role="button" title="xd9813_0-1588029664705.png" alt="xd9813_0-1588029664705.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;tried PROC Export next... same issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643438#M24006</guid>
      <dc:creator>xd9813</dc:creator>
      <dc:date>2020-04-27T23:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643439#M24007</link>
      <description>&lt;P&gt;What version of SAS are you using?&lt;/P&gt;
&lt;PRE&gt;162  %put &amp;amp;=sysvlong;
SYSVLONG=9.04.01M5P091317&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643439#M24007</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-27T23:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: ODS csv</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643441#M24008</link>
      <description>&lt;P&gt;Usually I see that error when I run code like in your original post. You opened the ODS destination, but never wrote anything to it, and then closed it. SAS does not make a working XLSX file in that case.&amp;nbsp; Not sure what a working XLSX file with no sheets in it would look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have an encoding issue? What encoding is your SAS session using? Does any of your character data using non-7 bit ASCII codes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are your Excel users getting access to the XLSX file? Do they have to move them via a file transfer tool like FTP? If so make sure to move them as binary and not as text.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 00:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-csv/m-p/643441#M24008</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-28T00:25:09Z</dc:date>
    </item>
  </channel>
</rss>

