<?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: Importing data with CR and LF endings with custom delimeters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812746#M320690</link>
    <description>&lt;P&gt;I understand that dlm is a column delimiter, but when the goal is to read an entire row of data into a single column only, I thought that might not matter.&amp;nbsp;Maybe a sample code will help. The goal is to read any text file (whether observations end with CR or LF), into one column with each line as a row in SAS. I'd like to achieve that in a single data step. Below is a conditional infile statement, but I don't think SAS supports it or it's just incorrect. I think another option is to change any LFs (\n) to CRs (\r) in data and then use termstr=CR. I tried that with Perl (&lt;STRONG&gt;_infile_= prxchange('s/\n/\r/', -1, _infile_)&lt;/STRONG&gt;), but instead of adding an actual carriage return, PRXCHANGE adds "\r" as a text: "sentence one as an example&lt;FONT color="#800000"&gt;&lt;STRONG&gt;\r&lt;/STRONG&gt;&lt;/FONT&gt;sentence_&amp;amp; "two" /. as ..." The issue here is how to convert LF into CR line-by-line during the datastep.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	infile datalines truncover;
	input x $100.;
	datalines;
sentence one	as an example
sentence_&amp;amp; "two" /. as an example
23 sentence three "'"' example
;

/* Create text file with CR endings */
%let txt = C:\test.txt;
filename out "&amp;amp;txt" termstr=cr;

data _null_;
	set test;
	file out;
	put x;
run;

data read; 
	infile "&amp;amp;txt" truncover termstr=cr end=eof;
	if eof then call symputx('nobs',_n_);
	input @;
	put "Lines read = &amp;amp;nobs" ;
	if &amp;amp;nobs &amp;gt; 1 then do;
		input y $100.;
	end;&lt;BR /&gt;&lt;BR /&gt;    /* Code below does not work */
	else do;
		infile "&amp;amp;txt" termstr=lf;
		input y $100.;
	end;
run;

proc print data=read;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 May 2022 17:48:14 GMT</pubDate>
    <dc:creator>Excelsius</dc:creator>
    <dc:date>2022-05-11T17:48:14Z</dc:date>
    <item>
      <title>Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812513#M320596</link>
      <description>&lt;P&gt;After spending quite some time, so far I have been unable to rectify this seemingly simple issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am importing txt files into SAS with an infile data step. There are two types of txt files: one type where each line ends with a carriage return (CR or \r) and another type where it ends with a line feed (LF or \n). I want a single program to handle either type of delimiter encountered (it's a macro) and my goal is to use a multi-delimeter specification dlm = " '0D'x, '0A'x " which covers CR and LF, respectively. Here is the issue: using dlm = '0A'x is a perfect substitute for termstr=LF, but when I try to substitute termstr=CR with dlm = '0D'x, this does not work and I have no idea why. What is the equivalent way to substitute termstr=CR with a specific delimiter? I have already checked my data in Notepad++ and confirmed that one text file has line endings with CR and another with LF.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 00:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812513#M320596</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-11T00:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812553#M320615</link>
      <description>&lt;P&gt;DLM = delimiter = char that separates variables&lt;/P&gt;
&lt;P&gt;termstr = separator between obs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without having termstr in the infile-statement, sas uses the default depending on the os sas runs on.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems as if dlm = " '0D'x, '0A'x " is processed correctly, because in the background termstr=LF is still active. &lt;/P&gt;
&lt;P&gt;I think the only way to solve the problem is by adding a parameter to the macro that is used in termstr later on.&lt;/P&gt;
&lt;P&gt;One could, of course, try to read the file with one termstr-option active and check the number of lines read. Then change the option and re-read the file again.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 06:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812553#M320615</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-11T06:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812623#M320639</link>
      <description>&lt;P&gt;DLM is for between VALUES.&lt;/P&gt;
&lt;P&gt;TERMSTR is for between LINES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to treat LINES as VALUES then use RECFM=N.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dat temp;
data _null_;
  file dat recfm=n ;
  put 'line one' '0D'x 'line two' '0D'x;
run;

data test;
  infile dat recfm=n dlm='0D'x ;
  input line :$80. ;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 May 2022 12:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812623#M320639</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-11T12:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812746#M320690</link>
      <description>&lt;P&gt;I understand that dlm is a column delimiter, but when the goal is to read an entire row of data into a single column only, I thought that might not matter.&amp;nbsp;Maybe a sample code will help. The goal is to read any text file (whether observations end with CR or LF), into one column with each line as a row in SAS. I'd like to achieve that in a single data step. Below is a conditional infile statement, but I don't think SAS supports it or it's just incorrect. I think another option is to change any LFs (\n) to CRs (\r) in data and then use termstr=CR. I tried that with Perl (&lt;STRONG&gt;_infile_= prxchange('s/\n/\r/', -1, _infile_)&lt;/STRONG&gt;), but instead of adding an actual carriage return, PRXCHANGE adds "\r" as a text: "sentence one as an example&lt;FONT color="#800000"&gt;&lt;STRONG&gt;\r&lt;/STRONG&gt;&lt;/FONT&gt;sentence_&amp;amp; "two" /. as ..." The issue here is how to convert LF into CR line-by-line during the datastep.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	infile datalines truncover;
	input x $100.;
	datalines;
sentence one	as an example
sentence_&amp;amp; "two" /. as an example
23 sentence three "'"' example
;

/* Create text file with CR endings */
%let txt = C:\test.txt;
filename out "&amp;amp;txt" termstr=cr;

data _null_;
	set test;
	file out;
	put x;
run;

data read; 
	infile "&amp;amp;txt" truncover termstr=cr end=eof;
	if eof then call symputx('nobs',_n_);
	input @;
	put "Lines read = &amp;amp;nobs" ;
	if &amp;amp;nobs &amp;gt; 1 then do;
		input y $100.;
	end;&lt;BR /&gt;&lt;BR /&gt;    /* Code below does not work */
	else do;
		infile "&amp;amp;txt" termstr=lf;
		input y $100.;
	end;
run;

proc print data=read;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 May 2022 17:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812746#M320690</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-11T17:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812751#M320693</link>
      <description>&lt;P&gt;If you just want to read the whole line into a single character variable then DLM will work if used with RECFM=N.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data read; 
  if eof then call symputx('nobs',_n_-1);
  infile dat dlm='0D0A'x recfm=n end=eof;
  input line :$100.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will work with lines terminated by CR, LF or CRLF.&lt;/P&gt;
&lt;P&gt;But this will not work if any of the lines have embedded CR or LF characters.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 18:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812751#M320693</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-11T18:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812772#M320699</link>
      <description>&lt;P&gt;I think this is the solution. Need to run some more tests to confirm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom, I actually did try what you suggested, except that I kept using &lt;STRONG&gt;dlm=" '0D'x '0A'x "&lt;/STRONG&gt; instead of&lt;STRONG&gt; '0D0A'x&lt;/STRONG&gt; and that was bringing in too many lines. However, I don't understand why&amp;nbsp;&lt;STRONG&gt;'0D0A'x&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;is working. I think that's equivalent to "CRLF," but the document contains either CR or LF and so technically this shouldn't work. Whereas I thought&amp;nbsp;&lt;STRONG&gt;" '0D'x '0A'x "&lt;/STRONG&gt;&amp;nbsp;means "CR&amp;nbsp;&lt;EM&gt;or&lt;/EM&gt; LF." Is my syntax off perhaps? Some insight would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, since I've gone down this rabbit hole too far at this point, I would still like to understand:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is it possible to have a conditional INFILE statement in a single datastep?&lt;/LI&gt;
&lt;LI&gt;Is it possible to replace CR with LF (or vice versa) when reading data into SAS?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 11 May 2022 18:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812772#M320699</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-11T18:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812785#M320705</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113285"&gt;@Excelsius&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think this is the solution. Need to run some more tests to confirm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom, I actually did try what you suggested, except that I kept using &lt;STRONG&gt;dlm=" '0D'x '0A'x "&lt;/STRONG&gt; instead of&lt;STRONG&gt; '0D0A'x&lt;/STRONG&gt; and that was bringing in too many lines. However, I don't understand why&amp;nbsp;&lt;STRONG&gt;'0D0A'x&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;is working. I think that's equivalent to "CRLF," but the document contains either CR or LF and so technically this shouldn't work. Whereas I thought&amp;nbsp;&lt;STRONG&gt;" '0D'x '0A'x "&lt;/STRONG&gt;&amp;nbsp;means "CR&amp;nbsp;&lt;EM&gt;or&lt;/EM&gt; LF." Is my syntax off perhaps? Some insight would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, since I've gone down this rabbit hole too far at this point, I would still like to understand:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is it possible to have a conditional INFILE statement in a single datastep?&lt;/LI&gt;
&lt;LI&gt;Is it possible to replace CR with LF (or vice versa) when reading data into SAS?&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Using&amp;nbsp;&lt;STRONG&gt;dlm=" '0D'x '0A'x "&lt;/STRONG&gt; means that you want to treat ANY of the six characters "0","D","'","x"," ", and "A" as a delimiter. Repeating the same character (like zero or single quote) multiple times does have any effect. So you essentially used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dlm=" '0DxA"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using '0D0A'x means you want the two byte string that is a CR and a LF to be the set of characters that are considered delimiters. So it does not matter if the lines are terminated with CR or LF or CRLF each of those three string will be considered a delimiter for the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make it dynamic use the&lt;STRONG&gt; name of a variable&lt;/STRONG&gt; in the DLM= option.&lt;/P&gt;
&lt;P&gt;For example you could make a character variable named DLM and use DLM=DLM.&amp;nbsp; Then when the INPUT statement runs it will use the current value of DLM as the set of delimiter characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length dlm $1 ;
infile csv dlm=dlm ..... ;

input x @;
if x=1 then dlm='0D'x;
else dlm='0A'x;

input .... ;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 19:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812785#M320705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-11T19:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812822#M320721</link>
      <description>Thanks Tom, seems like I had the incorrect syntax for the dlm initially. After running some tests, the '0D0A'x seems to be working fine. However, this syntax has created an issue where the line numbers (line_cnt+1) are incorrect, which I'm assuming is related to the recfm=n option because without it, the counts were correct for each line. If I don't figure out how to count lines correctly, I will have to look for a different solution. Do you know if there is a simple way to add a variable that will be the running count of the rows (1,2,3, etc)?&lt;BR /&gt;&lt;BR /&gt;The dlm=dlm example you posted is interesting. The usage in this case would be termstr=termstr, but x would have to be some function that would detect whether the input uses CR or LF: IF (input is LF) then termstr=LF. Not sure if SAS has a way of detecting line endings. Another test would be to detect if infile ends up being just a single line (meaning that termstr did not work), but I don't think this can be implemented inside a single data step.</description>
      <pubDate>Wed, 11 May 2022 23:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812822#M320721</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-11T23:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812836#M320730</link>
      <description>&lt;P&gt;After some more investigation, the specific issue is that if a given line only has LF or CR with no other characters (or spaces), it is not counted (n+1) with the &lt;STRONG&gt;recfm=n dlm='0A0D'x&lt;/STRONG&gt; method:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CR.jpg" style="width: 328px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71359iA5DF6660EFAC4CE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="CR.jpg" alt="CR.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here, line 3 is counted because it has 2 spaces, but lines 4 and 5 are not and these errors add up as lines proceed. This is not an issue when using termstr=LF rather than using a delimiter.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 01:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812836#M320730</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-12T01:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812843#M320733</link>
      <description>&lt;P&gt;That is normal behavior, multiple adjacent delimiters form one "word" boundary.&amp;nbsp; It is why this simple data step works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
   input x y;
cards;
  1  23
102 133
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try using the DSD option. That will treat adjacent delimiters as indicating an empty "word".&amp;nbsp; That is why you can read CSV files using code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   infile cards dsd truncover;
   input x y z;
cards;
1,2,3
4,,6
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that will have some other effects.&lt;/P&gt;
&lt;P&gt;Lines with CR &lt;STRONG&gt;and&lt;/STRONG&gt; LF as the end of line characters will be treated as TWO lines.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lines with quotes around them will have the quotes removed.&amp;nbsp; You can prevent this by using the ~ modifier on the INPUT statement.&lt;/P&gt;
&lt;P&gt;Lines that have CR or LF inside of quotes will NOT be split into two lines.&amp;nbsp; That might be a positive.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename LF temp termstr=lf;
options parmcards=LF;
parmcards;
line one
"line two"

line four


line seven
;

filename CR temp termstr=CR;
options parmcards=CR;
parmcards;
line one
"line two"

line four


line seven
;

data want1;
  infile LF dlm='0D0A'x dsd recfm=n;
  lineno+1;
  input line ~:$100.;
run;

data want2;
  infile CR dlm='0D0A'x dsd recfm=n;
  lineno+1;
  input line ~:$100.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 02:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812843#M320733</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-12T02:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812844#M320734</link>
      <description>&lt;P&gt;Your problem does not need dynamic changes to the delimiter.&amp;nbsp; That is for when you have lines of text where the delimiter changes for part of the line or part of the file.&amp;nbsp; You want to treat the whole file using the same delimiter once you figure out what it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can just read the beginning of the file and look for the first CR or LF character.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let termstr=;
data _null_;
   infile cr recfm=f lrecl=32767 obs=1;
   input;
   lf = indexc(_infile_,'0A'x);
   cr = indexc(_infile_,'0D'x);
   if lf and not cr then call symputx('termstr','termstr=LF');
   else if cr and not lf then call symputx('termstr','termstr=CR');
   else if cr+1=lf then call symputx('termstr','termstr=CRLF');
run;
%put &amp;amp;=termstr;
data want;
   infile cr &amp;amp;termstr truncover;
   lineno+1;
   input line $char100.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 03:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812844#M320734</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-12T03:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812845#M320735</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113285"&gt;@Excelsius&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;After some more investigation, the specific issue is that if a given line only has LF or CR with no other characters (or spaces), it is not counted (n+1) with the &lt;STRONG&gt;recfm=n dlm='0A0D'x&lt;/STRONG&gt; method:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CR.jpg" style="width: 328px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71359iA5DF6660EFAC4CE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="CR.jpg" alt="CR.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here, line 3 is counted because it has 2 spaces, but lines 4 and 5 are not and these errors add up as lines proceed. This is not an issue when using termstr=LF rather than using a delimiter.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I was able to reproduce your problem.&amp;nbsp; Then I added the INFILE option &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;DSD&lt;/STRONG&gt; &lt;/EM&gt;&lt;/U&gt;(delimiter sensitive data) and the null lines&amp;nbsp; were counted.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 03:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/812845#M320735</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-12T03:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/813246#M320915</link>
      <description>This is a great implementation of macros, which is what I was trying to figure out. It's an interesting way to call macros under _null_ and then use them in a data step. Technically it's still not a single data step, but an interesting implementation nevertheless. I can think of other areas I could apply a similar technique. Thanks for your insights.&lt;BR /&gt;&lt;BR /&gt;And yes, you were both correct that the issue had to do with dsd--that resolve the count issues.</description>
      <pubDate>Fri, 13 May 2022 15:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/813246#M320915</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-13T15:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/813247#M320916</link>
      <description>&lt;P&gt;There are no macros in the program I posted.&amp;nbsp; It does use a macro variable to facilitate the generation of the INFILE statement.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 15:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/813247#M320916</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-13T15:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Importing data with CR and LF endings with custom delimeters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/813321#M320970</link>
      <description>Obviously, was referring to macro variable usage under data _null_. That's why that code works and it can be expanded to other uses.</description>
      <pubDate>Sat, 14 May 2022 03:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-data-with-CR-and-LF-endings-with-custom-delimeters/m-p/813321#M320970</guid>
      <dc:creator>Excelsius</dc:creator>
      <dc:date>2022-05-14T03:05:09Z</dc:date>
    </item>
  </channel>
</rss>

