<?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: How to export a sas data having double quote in csv format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776347#M246885</link>
    <description>&lt;P&gt;The result you are getting is the expected result.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;I am expecting :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;NAME,AGE&lt;BR /&gt;"john","25"&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have this data in the CSV file, the quotes are seen as delimiters and stripped when the data is read.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output from this data is unquoted values.&lt;/P&gt;
&lt;P&gt;Since you export quoted values, SAS adds surrounding quotes so that the the values read from the CSV file are also quoted.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 01:33:30 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-10-26T01:33:30Z</dc:date>
    <item>
      <title>How to export a sas data having double quote in csv format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776326#M246873</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need your kind help to export a sas data having double quote in s=csv format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
name='john';
age='25';
run;


data have2;
set have (rename=(name=name1 age=age1));
name=quote(strip(name1));
age=quote(strip(age1));
drop name1 age1;
run;



proc export data=have2
outfile="M:\test\want.csv" dbms=csv replace;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;I am expecting :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;NAME,AGE&lt;BR /&gt;"john","25"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I am getting:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;NAME,AGE&lt;BR /&gt;"""john""","""25"""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you suggest revision in the existing code to get the desired output.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 23:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776326#M246873</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2021-10-25T23:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to export a sas data having double quote in csv format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776347#M246885</link>
      <description>&lt;P&gt;The result you are getting is the expected result.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;I am expecting :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;NAME,AGE&lt;BR /&gt;"john","25"&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have this data in the CSV file, the quotes are seen as delimiters and stripped when the data is read.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output from this data is unquoted values.&lt;/P&gt;
&lt;P&gt;Since you export quoted values, SAS adds surrounding quotes so that the the values read from the CSV file are also quoted.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 01:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776347#M246885</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-10-26T01:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to export a sas data having double quote in csv format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776348#M246886</link>
      <description>&lt;P&gt;Note that &lt;CODE&gt;proc export&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;can't wrap every (unquoted) field in double-quotes; the easiest one that will do this is the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%ds2csv()&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;macro.&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002683390.htm" target="_blank" rel="noopener"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002683390.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 01:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776348#M246886</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-10-26T01:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to export a sas data having double quote in csv format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776356#M246892</link>
      <description>&lt;P&gt;In a CSV file the quotes only need to be added when they are needed to protect delimiters (or to protect quotes themselves to avoid confusion).&lt;/P&gt;
&lt;P&gt;In your example data there is no need for the quotes because the values do not contain either delimiters or quotes.&amp;nbsp; So the proper file for that data is:&lt;/P&gt;
&lt;PRE&gt;NAME,AGE
john,25&lt;/PRE&gt;
&lt;P&gt;Please explain WHY you want a non-standard file format?&lt;/P&gt;
&lt;P&gt;If you really really need to have SAS add quotes just use the ~ modifier.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;
  file "M:\test\want.csv" dsd ;
  put (name age) (~);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to include the header row then write that first and then use the MOD option on the FILE statement when writing the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have(obs=0) out=names;
  var _all_;
run;
data _null_;
  set names;
  file "M:\test\want.csv" dsd ;
  put _name_ @ ;
run;
data _null_;
  set have;
  file "M:\test\want.csv" dsd mod;
  put (_all_) (~);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS How come the column headers don't have quotes around them in your example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 03:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-a-sas-data-having-double-quote-in-csv-format/m-p/776356#M246892</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-26T03:26:23Z</dc:date>
    </item>
  </channel>
</rss>

