<?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: QUOTE function csv/txt in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640922#M190980</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Thank you for your message. Sorry, It wasn't clear. I meant when I change .csv in .txt format manually.</description>
    <pubDate>Sat, 18 Apr 2020 08:06:10 GMT</pubDate>
    <dc:creator>SASdevAnneMarie</dc:creator>
    <dc:date>2020-04-18T08:06:10Z</dc:date>
    <item>
      <title>QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640823#M190950</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I make some data with QUOTE function. In my output, the csv file, I have the correct values like "City".&lt;/P&gt;
&lt;P&gt;When I convert the csv to txt file, I have the values like ""City"".&lt;/P&gt;
&lt;P&gt;I would like to have the same values ("City") in csv and txt files. Does it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 19:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640823#M190950</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2020-04-17T19:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640824#M190951</link>
      <description>&lt;P&gt;Could you please share the code you used to convert the csv to txt file&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 19:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640824#M190951</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-17T19:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640827#M190953</link>
      <description>&lt;P&gt;If you use PROC EXPORT or any of the automated exports to a CSV it will automatically encapsulate any field that requires it with quotes.&lt;STRONG&gt; If you've already included quotes, you need to use a data step to export your data instead&lt;/STRONG&gt; or rely on SAS automated exports.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everybody,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I make some data with QUOTE function. In my output, the csv file, I have the correct values like "City".&lt;/P&gt;
&lt;P&gt;When I convert the csv to txt file, I have the values like ""City"".&lt;/P&gt;
&lt;P&gt;I would like to have the same values ("City") in csv and txt files. Does it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 19:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640827#M190953</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-17T19:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640830#M190954</link>
      <description>Thank you for your message. I do the conversation manually.</description>
      <pubDate>Fri, 17 Apr 2020 19:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640830#M190954</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2020-04-17T19:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640831#M190955</link>
      <description>Thank you for your answer. &lt;BR /&gt; When I don't include the additional quotes to csv, don't have the quotes in txt. As you wrote, I must have one.</description>
      <pubDate>Fri, 17 Apr 2020 20:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640831#M190955</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2020-04-17T20:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640834#M190956</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for your answer. &lt;BR /&gt;When I don't include the additional quotes to csv, don't have the quotes in txt. As you wrote, I must have one.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please explain in detail what you are trying to achieve. You can ask the SAS data step to add quotes by using the ~ modifier in the PUT statement.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;2271  data _null_;
2272   set sashelp.class (obs=3);
2273   file log dsd ;
2274   put name age sex ~ height weight ;
2275  run;

Alfred,14,"M",69,112.5
Alice,13,"F",56.5,84
Barbara,13,"F",65.3,98
NOTE: There were 3 observations read from the data set SASHELP.CLASS.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 20:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640834#M190956</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-17T20:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640839#M190957</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everybody,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I make some data with QUOTE function. In my output, the csv file, I have the correct values like "City".&lt;/P&gt;
&lt;P&gt;When I convert the csv to txt file, I have the values like ""City"".&lt;/P&gt;
&lt;P&gt;I would like to have the same values ("City") in csv and txt files. Does it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is not at all apparent what you are talking about. Can you provide example data and programs?&amp;nbsp; Please post the information using the Insert Code or Insert SAS code buttons to preserve the formatting of the text.&amp;nbsp; Copy in a program to create the sample SAS dataset. Program to create the CSV file. And examples of what you want and how what you are getting is different than what you want.&amp;nbsp; You probably need only create two or three lines of data for two or three variables to represent your issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that a CSV files IS a text file.&amp;nbsp; It is just one that has commas between the values, Comma Separated Values.&amp;nbsp; If the values contain the comma then they value needs to be in quotes. So if the value for a field is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1,234&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then it will be represented in the file as&lt;/P&gt;
&lt;PRE&gt;"1,234"&lt;/PRE&gt;
&lt;P&gt;so that it is not considered two values instead of one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That means that if you want to have actual quotes in the data then they also need to be in quotes to prevent them from being interpreted as quotes meant to protect the embedded commas.&amp;nbsp; Once they are in quotes then the actual quotes need to be doubled so that your can tell they are part of the data and not just the quotes added to protect the commas.&amp;nbsp; So if you data is&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"city"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then in the CSV file this needs to be represented by&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"""city"""&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The outer quotes will be removed and the inner ones duplicates will be replaced.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 20:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640839#M190957</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-17T20:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640842#M190958</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for your answer. &lt;BR /&gt;When I don't include the additional quotes to csv, don't have the quotes in txt. As you wrote, I must have one.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It includes quotes on fields that require them, not all fields. So if a field has a comma or quote, then it will get masked, otherwise it won't. You don't necessarily need all fields quotes in your export. If you want that, use a data step to export your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run both examples below, changing the paths to what's appropriate for you use case of course.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
length name $20. sex $5.;
set sashelp.class;
if name ='Alfred' then name = 'Al,Fred';
if name='Jane' then name = "Ja'ne";
*name = quote(trim(name));
*sex=quote(trim(sex));
run;

proc export data=demo outfile="/home/fkhurshed/Demo1/demo1.csv" dbms=csv replace;run;


data demo;
length name $20. sex $5.;
set sashelp.class;
if name ='Alfred' then name = 'Al,Fred';
if name='Jane' then name = "Ja'ne";
name = quote(trim(name));
sex=quote(trim(sex));
run;

proc transpose data=demo(obs=0) out=names;
  var _all_;
run;

data _null_ ;
  file "/home/fkhurshed/Demo1/demo2.csv" dsd ;
  set names end=eof;
  put _name_ @ ;
  if eof then put;
run;


data _null_;
set demo;
  file "/home/fkhurshed/Demo1/demo2.csv" dlm=',' MOD;
 put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 20:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640842#M190958</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-17T20:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640844#M190959</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for your answer. &lt;BR /&gt;When I don't include the additional quotes to csv, don't have the quotes in txt. &lt;STRONG&gt;As you wrote, I must have one.&lt;/STRONG&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, you do not require quotes around all character variables in a well formed CSV. You only require quotes around fields that have an embedded character that could cause issues such as a comma or quote.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not require them around all fields. That's the approach many users take rather than bother to figure out which observations need to be masked. It's easier to include quotes around everything, but that isn't necessarily 'better'. It makes the file larger by default.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 20:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640844#M190959</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-17T20:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640886#M190970</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; When I convert the csv to txt file&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;This phrase makes no sense: CSV files &lt;STRONG&gt;are&lt;/STRONG&gt; text files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You really must explain and show us what exactly you are doing.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 23:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640886#M190970</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-17T23:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640922#M190980</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Thank you for your message. Sorry, It wasn't clear. I meant when I change .csv in .txt format manually.</description>
      <pubDate>Sat, 18 Apr 2020 08:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640922#M190980</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2020-04-18T08:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: QUOTE function csv/txt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640923#M190981</link>
      <description>Thank you very much,Reeza, it works. &lt;BR /&gt;I understand the difference beetwing using the proc export and file export.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Marie</description>
      <pubDate>Sat, 18 Apr 2020 08:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/QUOTE-function-csv-txt/m-p/640923#M190981</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2020-04-18T08:09:40Z</dc:date>
    </item>
  </channel>
</rss>

