<?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: Choose delimiter in proc export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894222#M353237</link>
    <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;May you please show the code where I need to add&amp;nbsp; DSD option?&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;Do you mean that I need to run "Way2" and not "Way1"?&lt;/P&gt;
&lt;P&gt;Which way is better- way2 or way1?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/********Way1***************/
/********Way1***************/
/********Way1***************/
libname LS '/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/';
proc export data=LS.lightSolver_sofi(obs=10) 
outfile='/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/lightSolver_sofi.txt'
dbms = dlm  replace;
delimiter = '|';
run;

/********Way2***************/
/********Way2***************/
/********Way2***************/
libname LS '/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/';
%macro export_flat_files;
%let file_extract='/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/lightSolver_sofi2.txt';
%put &amp;amp;file_extract;
data _null_;
file &amp;amp;file_extract dsd dlm = '|';
set LS.lightSolver_sofi(obs=10) ;
put (_all_) (~);
run;
%mend;
%export_flat_files;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Sep 2023 06:50:09 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2023-09-14T06:50:09Z</dc:date>
    <item>
      <title>Choose delimiter in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894211#M353228</link>
      <description>Hello&lt;BR /&gt;I have a very big data set of 150 million rows with 5 char columns and 15 numeric.I want to check which special characters ( characters that are not numbers and not letters) are in the char columns. It will help me to choose the delimiter when i export the data set into txt file. I must choose delimiter that is not existing as special character in char columns</description>
      <pubDate>Thu, 14 Sep 2023 02:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894211#M353228</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-14T02:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Choose delimiter in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894213#M353230</link>
      <description>&lt;P&gt;Why do you think it matters what delimiter you use?&amp;nbsp; SAS will create a valid CSV file with any delimiter.&amp;nbsp; If any value includes the delimiter (or a quote) then the value will be quoted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sounds like your real problem is that the consumer of the file does not know how to read a CSV file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really must try to find a character that never appears in your data then you will have make two passes thru the data.&amp;nbsp; One to check for a possible delimiter&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set have end=eof;
   array _c _character_;
   length _x $128;
   retain _x ;
   if _n_=1 then do;
      _x=collate(0,128);
      _x=compress(_x,cat(' ','00'x,'FF'x,'"'),'DF');
  end;
  do over _c;
    _x = compress(_x,_c);
   end;
   if eof then call symputx('dlm',put(_x,$hex2.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and a second to actually write the CSV file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=have file="want.csv" dbms=csv;
   delimiter="&amp;amp;dlm"x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Sep 2023 03:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894213#M353230</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-14T03:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Choose delimiter in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894215#M353232</link>
      <description>Thanks,&lt;BR /&gt;If I use delimiter that appears in the char columns then  when the user of the txt file will import it into sas then SAS can mix values from different columns.&lt;BR /&gt;This is my opinion, what do you think?</description>
      <pubDate>Thu, 14 Sep 2023 05:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894215#M353232</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-14T05:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Choose delimiter in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894217#M353234</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks,&lt;BR /&gt;If I use delimiter that appears in the char columns then when the user of the txt file will import it into sas then SAS can mix values from different columns.&lt;BR /&gt;This is my opinion, what do you think?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. By using the DSD option, columns containing the delimiter will be quoted. The only real "troublemakers" are LF or CRLF, which should be eliminated from the data anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 05:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894217#M353234</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-14T05:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Choose delimiter in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894222#M353237</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;May you please show the code where I need to add&amp;nbsp; DSD option?&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;Do you mean that I need to run "Way2" and not "Way1"?&lt;/P&gt;
&lt;P&gt;Which way is better- way2 or way1?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/********Way1***************/
/********Way1***************/
/********Way1***************/
libname LS '/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/';
proc export data=LS.lightSolver_sofi(obs=10) 
outfile='/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/lightSolver_sofi.txt'
dbms = dlm  replace;
delimiter = '|';
run;

/********Way2***************/
/********Way2***************/
/********Way2***************/
libname LS '/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/';
%macro export_flat_files;
%let file_extract='/usr/local/SAS/SASUsers/LabRet/Adhoc/creditCards/lightSolver_sofi2.txt';
%put &amp;amp;file_extract;
data _null_;
file &amp;amp;file_extract dsd dlm = '|';
set LS.lightSolver_sofi(obs=10) ;
put (_all_) (~);
run;
%mend;
%export_flat_files;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 06:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894222#M353237</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-14T06:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Choose delimiter in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894261#M353256</link>
      <description>&lt;P&gt;Read the log to see the code generated by PROC EXPORT. You may already see the option used there.&lt;/P&gt;
&lt;P&gt;If you write the DATA step yourself, don't forget a LRECL= option with a sufficient size for the output buffer.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 13:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-delimiter-in-proc-export/m-p/894261#M353256</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-14T13:41:53Z</dc:date>
    </item>
  </channel>
</rss>

