<?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 import a csv in SAS to change the delimiter and export it again with the new delimiter in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795023#M32904</link>
    <description>&lt;P&gt;It's almost perfect, thank you very much, the only problem I have is that for example:&lt;/P&gt;&lt;P&gt;In the original csv the first row would be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;"Hello"|"what"||"hello"||||&lt;/P&gt;&lt;P&gt;And I want it like this:&lt;BR /&gt;"Hello"|"what"|""|"hello"|""|""|""|&lt;/P&gt;&lt;P&gt;And with the solution that you has given to me, it returns the following:&lt;BR /&gt;"Hello"|"what"|""|"hello"|""|&lt;/P&gt;&lt;P&gt;It eliminates the last 2 fields, which I want to simply be empty, but they are, I have a total of 11 fields.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2022 17:01:52 GMT</pubDate>
    <dc:creator>Abelp9</dc:creator>
    <dc:date>2022-02-08T17:01:52Z</dc:date>
    <item>
      <title>How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795013#M32899</link>
      <description>&lt;P&gt;Hello everyone, I'm new to SAS programming so forgive my possible ignorance in advance.&lt;/P&gt;&lt;P&gt;I would like to create a program that takes a csv file that has a delimiter of '||' and I want to change it to '|""|' with two double quotes between the slashes (|).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then, once the csv is transformed export it to the same path where it was.&lt;/P&gt;&lt;P&gt;The part of exporting the file is clear to me, what I fail to do is import the csv file and change its delimiter. This is what i tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*IMPORT;&lt;/P&gt;&lt;P&gt;proc import file="/XX/XX/XX/XX/X/XX/XX/XXX.csv"&lt;BR /&gt;out=work.test&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;DELIMITER= '|""|';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*EXPORT;&lt;/P&gt;&lt;P&gt;proc export data=work.test&lt;BR /&gt;outfile="/xx/xx/xx/xx/CA/xx/xx/xx.csv"&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The export works for me but there are errors in the import, it returns this error: ERROR: Quotes (' or ") have been detected in the delimiter (DLM=) string. Quotes cannot be used as delimiter characters when the DSD option is also specified.&amp;nbsp;If someone could help me / explain how to do it I would be extremely grateful, thank you very much in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 16:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795013#M32899</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-08T16:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795016#M32901</link>
      <description>&lt;P&gt;If you just want to read it in and write it out then don't bother trying to interpret it. Just copy it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile original dlmstr='||' length=ll column=cc truncover ;
  file new dlmstr='|""|' ;
  do until(cc&amp;gt;ll);
    input value :$32767. @;
    put value @;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 16:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795016#M32901</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-08T16:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795021#M32903</link>
      <description>what does it means cc&amp;gt;11? can you explain me the code please?? thank you very much</description>
      <pubDate>Tue, 08 Feb 2022 16:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795021#M32903</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-08T16:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795023#M32904</link>
      <description>&lt;P&gt;It's almost perfect, thank you very much, the only problem I have is that for example:&lt;/P&gt;&lt;P&gt;In the original csv the first row would be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;"Hello"|"what"||"hello"||||&lt;/P&gt;&lt;P&gt;And I want it like this:&lt;BR /&gt;"Hello"|"what"|""|"hello"|""|""|""|&lt;/P&gt;&lt;P&gt;And with the solution that you has given to me, it returns the following:&lt;BR /&gt;"Hello"|"what"|""|"hello"|""|&lt;/P&gt;&lt;P&gt;It eliminates the last 2 fields, which I want to simply be empty, but they are, I have a total of 11 fields.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 17:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795023#M32904</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-08T17:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795026#M32905</link>
      <description>&lt;P&gt;Check the INFILE statement.&lt;/P&gt;
&lt;P&gt;LL is the variable that SAS is setting to the LENGTH of the current line in the file being read.&lt;/P&gt;
&lt;P&gt;CC is the variable that SAS is setting to the COLUMN that will next be read from the current line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if CC is larger than LL you have read past the end of the line.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 17:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795026#M32905</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-08T17:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795028#M32906</link>
      <description>no consigo visualizar lo que me dices :(...&lt;BR /&gt;¿Dónde podría estar mi fallo? parece que no esta leyendo la linea entera?</description>
      <pubDate>Tue, 08 Feb 2022 17:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795028#M32906</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-08T17:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795030#M32907</link>
      <description>&lt;P&gt;So your delimiter is in fact not&lt;/P&gt;
&lt;PRE&gt;|""|&lt;/PRE&gt;
&lt;P&gt;but a single pipe (|) character, and your fields are enclosed in quotes.&lt;/P&gt;
&lt;P&gt;See this for starters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out temp;

data _null_;
infile datalines dlm="|" truncover;
file out dlm="|";
input (text1-text8) (:$10.);
array text {*} text1-text8;
do i = 1 to 8;
  if text{i} = '' then text{i} = '""';
end;
put text1-text8;
datalines;
"Hello"|"what"||"hello"||||
;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 17:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795030#M32907</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-08T17:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795034#M32908</link>
      <description>&lt;P&gt;That sounds different than your original explanation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That input file appears to be using | as a delimter and not || as a delimiter string.&amp;nbsp; Let's try telling SAS that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=original;
filename original temp;
filename new temp;
parmcards4;
"Hello"|"what"||"hello"||||
;;;;

data _null_;
  infile original dlm='|' dsd length=ll column=cc truncover ;
  file new dlmstr='|""|' ;
  do until(cc&amp;gt;ll);
    input value :$32767. @;
    put value @;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results;&lt;/P&gt;
&lt;PRE&gt;259   data _null_;
260     infile new;
261     input;
262     put _infile_;
263   run;

NOTE: The infile NEW is:
      Filename=...\#LN00067,
      RECFM=V,LRECL=32767,File Size (bytes)=44,
      Last Modified=08Feb2022:12:12:12,
      Create Time=08Feb2022:12:12:12

Hello|""|what|""| |""|hello|""| |""| |""|
NOTE: 1 record was read from the infile NEW.
      The minimum record length was 42.
      The maximum record length was 42.
&lt;/PRE&gt;
&lt;P&gt;Your output example is also a problem.&amp;nbsp; If you use DMLSTR then you will not automatically have missing values not generate any text into the file.&amp;nbsp; That is because you cannot use the DSD option with a DLMSTR value that includes quotes.&amp;nbsp; That is because the DSD option will add quotes around values that contain the delimiter so it garfs if try to use a quote as part of the delimiter string.&amp;nbsp; (Note the SAS error message mistakenly will mention DLM instead of DLMSTR.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really did need to not write anything for missing values you might need to add more logic to handle that.&lt;/P&gt;
&lt;P&gt;If you really want the around the values written (why?) then you might want to use the ~ modifier?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the lines are short enough and there are no | characters in the values of any of the fields it might be easier to just read the whole line and modify it yourself and re-write it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=original;
filename original temp;
filename new temp;
parmcards4;
"Hello"|"what"||"hello"||||
1|2|3|4|5|6|7|8
;;;;

data _null_;
  infile original truncover ;
  file new ;
  input line $char32767.;
  line=tranwrd(line,'|','|""|');
  len=lengthn(line);
  put line $varying32767. len;
run;

data _null_;
  infile new;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;"Hello"|""|"what"|""||""|"hello"|""||""||""||""|
1|""|2|""|3|""|4|""|5|""|6|""|7|""|8
&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 17:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795034#M32908</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-08T17:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795040#M32909</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415512"&gt;@Abelp9&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;no consigo visualizar lo que me dices :(...&lt;BR /&gt;¿Dónde podría estar mi fallo? parece que no esta leyendo la linea entera?&lt;HR /&gt;
&lt;P&gt;I can't visualize what you say :(...&lt;BR /&gt;Where could my fault be? It seems that you are not reading the entire line?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Exactly.&amp;nbsp; It is reading and writing each field not each line.&amp;nbsp; The DO loop make sure it reads all of the line and stops when there is nothing left.&lt;/P&gt;
&lt;P&gt;This solves two problems.&lt;/P&gt;
&lt;P&gt;1) There is a limit of 32.767 bytes that can be used for a character variable.&amp;nbsp; But a line of a file could have millions of bytes.&lt;/P&gt;
&lt;P&gt;2) The DSD option will handle reading lines where the values contain the delimiters (as long as those values are properly quoted).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 17:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795040#M32909</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-08T17:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795048#M32910</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415512"&gt;@Abelp9&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It's almost perfect, thank you very much, the only problem I have is that for example:&lt;/P&gt;
&lt;P&gt;In the original csv the first row would be like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;"Hello"|"what"||"hello"||||&lt;/P&gt;
&lt;P&gt;And I want it like this:&lt;BR /&gt;"Hello"|"what"|""|"hello"|""|""|""|&lt;/P&gt;
&lt;P&gt;And with the solution that you has given to me, it returns the following:&lt;BR /&gt;"Hello"|"what"|""|"hello"|""|&lt;/P&gt;
&lt;P&gt;It eliminates the last 2 fields, which I want to simply be empty, but they are, I have a total of 11 fields.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has posted it looks like your original file is just using | as the delimiter. But it has some unneeded extra quotes around the values.&amp;nbsp; &amp;nbsp;The more natural way to represent those values in a | delimited file would be as:&lt;/P&gt;
&lt;PRE&gt;Hello|what||hello||||&lt;/PRE&gt;
&lt;P&gt;Since none of the three non-empty values contain either the delimiter | nor any quote characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you feel a need to add even more quotes to the file?&lt;/P&gt;
&lt;P&gt;Is it not working for some purpose?&amp;nbsp; What purpose?&lt;/P&gt;
&lt;P&gt;Are you trying to read it with some other software?&amp;nbsp; What software?&amp;nbsp; Why does it need extra quotes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a modified data step that uses ~ modifier to preserve any existing quotes in the fields and also replaces empty fields with "".&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile original dlm='|' dsd length=ll column=cc truncover ;
  file new dlm='|' ;
  do until(cc&amp;gt;ll);
    input value ~ :$char32767. @;
    if missing(value) then value ='""';
    put value :$char32767. @;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 18:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795048#M32910</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-08T18:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795116#M32913</link>
      <description>&lt;P&gt;I think you are not understanding me well or I am not explaining myself well, my delimiter is not "|", it is "||". They send me csv files that in the cells that are empty they put them as ||, instead of |""|. So I always have to open notepad and replace || by |""|.&lt;/P&gt;&lt;P&gt;What I want to do is automate this, and create a program that directly takes these csvs and transforms them by changing the || by |""|.&lt;/P&gt;&lt;P&gt;The solution that they gave me at the beginning worked for me, the only problem is that I was missing variables&lt;/P&gt;&lt;P&gt;Source CSV:&lt;BR /&gt;|"Hello"|"what"|"hello"|||| (6 variables)&lt;/P&gt;&lt;P&gt;CSV I want:&lt;BR /&gt;|"Hello"|"what"|"hello"|""|""|""| (6 variables with "" between the bars)&lt;/P&gt;&lt;P&gt;Thank you very much for your help, and I'm sorry if I'm explaining myself wrong, I don't have much experience in SAS&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 08:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795116#M32913</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-09T08:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795117#M32914</link>
      <description>&lt;P&gt;your result is: "Hello"|""|"what"|""||""|"hello"|""||""||""||""|&lt;BR /&gt;1|""|2|""|3|""|4|""|5|""|6|""|7|""|8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I would need:&lt;BR /&gt;"Hello"|""|"what"|""|""|""|"hello"|""|""|""|""|""|""|""|&lt;BR /&gt;1|""|2|""|3|""|4|""|5|""|6|""|7|""|8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there can be no slashes without quotes&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 08:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795117#M32914</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-09T08:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795118#M32915</link>
      <description>&lt;P&gt;You contradict yourself:&lt;/P&gt;
&lt;P&gt;First you say&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;my delimiter is not "|", it is "||"&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;but then you say&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;|"Hello"|"what"|"hello"|||| (6 variables)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If you had double pipes as delimiters, you would have three variables and not 6.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And keep in mind that those quotes are &lt;U&gt;around&lt;/U&gt; the values, they are &lt;U&gt;not part&lt;/U&gt; of the values, so they are not needed for missing values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you really think you need quotes as part of value, explain why.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 08:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795118#M32915</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-09T08:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795120#M32916</link>
      <description>&lt;P&gt;You are also moving the goalposts here, in your first post the data had no leading pipe. Please clarify this.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 08:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795120#M32916</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-09T08:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795122#M32917</link>
      <description>parmcards4 it does not work</description>
      <pubDate>Wed, 09 Feb 2022 08:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795122#M32917</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-09T08:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795134#M32918</link>
      <description>&lt;P&gt;Excuse me, I'm new to SAS programming and I'm still explaining myself wrong, I'm going to share screenshots of what they give me and how I want it.&lt;/P&gt;&lt;P&gt;I receive the csv in this way (it is opened with notepad):&lt;/P&gt;&lt;P&gt;&lt;A href="https://ibb.co/202PwDM" target="_blank" rel="noopener"&gt;https://ibb.co/202PwDM&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then with notepad I do search &amp;lt; replace &amp;lt; and replace || by |""|&lt;/P&gt;&lt;P&gt;this way I get this final csv (this is what i want):&lt;/P&gt;&lt;P&gt;&lt;A href="https://ibb.co/PZ3KT7x" target="_blank" rel="noopener"&gt;https://ibb.co/PZ3KT7x&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how I want the csv, and I want to do this process of importing the csv, transforming it and exporting it in SAS,&lt;/P&gt;&lt;P&gt;with this code that you have kindly provided me:&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;infile "xxx/xxx&lt;SPAN&gt;.csv" dlm='|' dsd length=ll column=cc truncover ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;file "xxx/xxx&lt;SPAN&gt;.csv"&lt;/SPAN&gt; dlm='|' ;&lt;BR /&gt;do until(cc&amp;gt;ll);&lt;BR /&gt;input value ~ :$char32767. @;&lt;BR /&gt;if missing(value) then value ='""';&lt;BR /&gt;put value :$char32767. @;&lt;BR /&gt;end;&lt;BR /&gt;put;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;i got this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ibb.co/ZK4KHTj" target="_blank" rel="noopener"&gt;https://ibb.co/ZK4KHTj&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I am missing the last bar on the right (look at the csv I want), why is this happening? how can i fix it to get the csv i want (exactly like this but with a trailing slash too)&lt;/P&gt;&lt;P&gt;Thank you very much for all the help you give me&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 10:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795134#M32918</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-09T10:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795173#M32919</link>
      <description>&lt;P&gt;So the DO loop is not detecting the last empty value.&lt;/P&gt;
&lt;P&gt;There are ways to fix that. Y&lt;SPAN&gt;ou could&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;just hard code the number of fields into the DO loop instead of trying to have it detect the number of fields.&amp;nbsp; If you don't know in advance how many fields there are try checking if the last character on the line is the delimiter and add one more field when it is.&amp;nbsp; Or try reading the whole file to get a count of the maximum number of fields found.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile original dlm='|' dsd truncover ;
  file new dlm='|' ;
  do col=1 to 8 until(cc&amp;gt;ll);
    input value ~ :$char32767. @;
    if cc&amp;lt;ll then input nextch $char1. +(-1) @;
    if missing(value) then value ='""';
    put value :$char32767. @;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;823   data _null_;
824     infile new;
825     input;
826     n=countc(_infile_,'|');
827     put n= _infile_;
828   run;

NOTE: The infile NEW is:
      Filename=...\#LN00107,
      RECFM=V,LRECL=32767,File Size (bytes)=56,
      Last Modified=09Feb2022:08:41:17,
      Create Time=09Feb2022:08:41:17

n=7 "Hello"|"what"|""|"hello"|""|""|""|""
n=7 1|2|3|4|5|6|7|8
NOTE: 2 records were read from the infile NEW.
      The minimum record length was 15.
      The maximum record length was 37.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another method you could use when the lines (after inserting the extra quotes) are shorter than 32,767 bytes is to replicate your manual process.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile original truncover ;
  file new dlm='|' ;
  input line $char32767.;
  line=tranwrd(line,'||','|""|');
  length = lengthn(line);
  put line $varying32767. length; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;840   data _null_;
841     infile new;
842     input;
843     n=countc(_infile_,'|');
844     put n= _infile_;
845   run;

NOTE: The infile NEW is:
      Filename=...\#LN00107,
      RECFM=V,LRECL=32767,File Size (bytes)=52,
      Last Modified=09Feb2022:08:41:17,
      Create Time=09Feb2022:08:41:17

n=7 "Hello"|"what"|""|"hello"|""||""|
n=7 1|2|3|4|5|6|7|8
NOTE: 2 records were read from the infile NEW.
      The minimum record length was 15.
      The maximum record length was 33.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice how there is a slight difference.&lt;/P&gt;
&lt;PRE&gt;"Hello"|"what"|""|"hello"|""||""|
"Hello"|"what"|""|"hello"|""|""|""|""&lt;/PRE&gt;
&lt;P&gt;You can adjust to repeat the replacing until all of the || have had "" inserted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile original truncover ;
  file new dlm='|' ;
  input line $char32767.;
  do while (index(line,'||'));
    line=tranwrd(line,'||','|""|');
  end;
  length = lengthn(line);
  put line $varying32767. length; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;874   data _null_;
875     infile new;
876     input;
877     n=countc(_infile_,'|');
878     put n= _infile_;
879   run;

NOTE: The infile NEW is:
      Filename=...\#LN00107,
      RECFM=V,LRECL=32767,File Size (bytes)=54,
      Last Modified=09Feb2022:08:56:14,
      Create Time=09Feb2022:08:41:17

n=7 "Hello"|"what"|""|"hello"|""|""|""|
n=7 1|2|3|4|5|6|7|8
NOTE: 2 records were read from the infile NEW.
      The minimum record length was 15.
      The maximum record length was 35.
&lt;/PRE&gt;
&lt;P&gt;Here is your photograph:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CSV-que-quiero.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68305iD1E606C26FBE90B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="CSV-que-quiero.png" alt="CSV-que-quiero.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;You still have not explained why a NORMAL delimited file without all of those extra quotes is not sufficient.&lt;/STRONG&gt;&amp;nbsp; What are you going to DO with the new file?&amp;nbsp; What happens when you use a normal CSV file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should also try other types of lines.&lt;/P&gt;
&lt;P&gt;What about when the last field is not empty?&lt;BR /&gt;What about when one or more of the fields is numeric instead of character?&amp;nbsp; Do you still need the quotes then? Or do they cause trouble?&amp;nbsp; An example of where they can cause trouble is if you are using PROC IMPORT to read the file.&amp;nbsp; SAS will (mistakenly) convert any field that has quotes around it on every line into a character string.&amp;nbsp; Even if it just has quotes because the way the numbers are displayed they include commas. So adding unneeded quotes can have negative side effects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Please learn how to use the forum editor.&amp;nbsp; Use the &lt;STRONG&gt;Insert Code&lt;/STRONG&gt; icon to insert text.&amp;nbsp; Use the &lt;STRONG&gt;Insert SAS Code&lt;/STRONG&gt; icon to insert SAS code.&amp;nbsp; Use the &lt;STRONG&gt;Insert Photos&lt;/STRONG&gt; icon to insert photographs.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 14:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795173#M32919</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-09T14:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a csv in SAS to change the delimiter and export it again with the new delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795182#M32920</link>
      <description>&lt;P&gt;Thank you for your help, your God&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 14:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-a-csv-in-SAS-to-change-the-delimiter-and-export-it/m-p/795182#M32920</guid>
      <dc:creator>Abelp9</dc:creator>
      <dc:date>2022-02-09T14:39:49Z</dc:date>
    </item>
  </channel>
</rss>

