<?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: Creating Delimited File with Embedded delimiter in Data values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741069#M231630</link>
    <description>&lt;P&gt;This means we enclose data values in " " and handle these quoted values in Python ?.&lt;/P&gt;</description>
    <pubDate>Thu, 13 May 2021 11:56:28 GMT</pubDate>
    <dc:creator>PRAVIN_JAIN</dc:creator>
    <dc:date>2021-05-13T11:56:28Z</dc:date>
    <item>
      <title>Creating Delimited File with Embedded delimiter in Data values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741037#M231610</link>
      <description>&lt;P&gt;I need to convert dataset into flat file with "}" as delimiter. One of the field in dataset has } in data values due to which it is being considered as an extra column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset -&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Accepted&lt;/P&gt;&lt;P&gt;Accepted}&lt;/P&gt;&lt;P&gt;{Accepted}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to handle this while converting into flat file, flat file will be read by Python program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 07:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741037#M231610</guid>
      <dc:creator>PRAVIN_JAIN</dc:creator>
      <dc:date>2021-05-13T07:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Delimited File with Embedded delimiter in Data values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741044#M231613</link>
      <description>&lt;P&gt;I think there is a problem with python reading, but you could try using $QUOTE. format to handle quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length var1 var2 $20;
  input var1 var2;
datalines;
Accepted Accepted
Accepted} Accepted}
{Accepted} {Accepted}
;
run;

filename x temp ;
data _null_;
  set have;
  file x dlm='}';
  format var1-var2 $QUOTE.;
  put var1 var2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result is below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-05-13_17h40_05.png" style="width: 326px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59306iA31DA3F4DA5C1764/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-05-13_17h40_05.png" alt="2021-05-13_17h40_05.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 08:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741044#M231613</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-05-13T08:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Delimited File with Embedded delimiter in Data values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741047#M231614</link>
      <description>&lt;P&gt;It depends on what software is reading the flat file. Another option (besides quoting as suggested) is to escape the } by adding a \ before }, using for example function transtrn().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 09:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741047#M231614</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-05-13T09:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Delimited File with Embedded delimiter in Data values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741069#M231630</link>
      <description>&lt;P&gt;This means we enclose data values in " " and handle these quoted values in Python ?.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 11:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741069#M231630</guid>
      <dc:creator>PRAVIN_JAIN</dc:creator>
      <dc:date>2021-05-13T11:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Delimited File with Embedded delimiter in Data values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741075#M231633</link>
      <description>&lt;P&gt;Any software that reads/writes delimited files has mechanisms to deal with embedded delimiters, usually by using quotes. In SAS this is done with the DSD option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
file "outfile" dlm="}" dsd;
set have;
put var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will automatically enclose values containing the delimiter in double quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 12:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741075#M231633</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-13T12:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Delimited File with Embedded delimiter in Data values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741115#M231638</link>
      <description>&lt;P&gt;SAS will normally generate readable delimited files.&amp;nbsp; When the value contains the delimiter the whole value is enclosed in quotes.&amp;nbsp; Because of this any file that contains a quote is also enclosed in quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input row (var1-var2) (:$20.);
datalines;
1 Accepted   Yes
2 Accepted}  No
3 {Accepted} "Maybe"
;

filename csv temp;
data _null_;
  set have;
  file csv dsd dlm='}';
  put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;1}Accepted}Yes
2}"Accepted}"}No
3}"{Accepted}"}"""Maybe"""
&lt;/PRE&gt;
&lt;P&gt;Check the python program to make sure it is reading the file properly.&lt;/P&gt;
&lt;P&gt;If you are desperate you might preprocess the data to add \ in front of and delimiters.&amp;nbsp; A lot of programs that take their clues for how to process text for the conventions of unix shell scripts use that character to "escape" the next character.&amp;nbsp; But in that case make sure to also escape and escape characters in the strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input row (var1-var2) (:$20.);
datalines;
1 Accepted   Yes
2 Accepted}  No
3 {Accepted} Yes\No
;
filename csv temp;
data _null_;
  set have;
  array _c _character_;
  do over _c;
    _c=tranwrd(_c,'\','\\');
    _c=tranwrd(_c,'}','\}');
  end;
  file csv  dlm='}';
  put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;1}Accepted}Yes
2}Accepted\}}No
3}{Accepted\}}Yes\\No
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 13:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Delimited-File-with-Embedded-delimiter-in-Data-values/m-p/741115#M231638</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-13T13:52:45Z</dc:date>
    </item>
  </channel>
</rss>

