<?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: INFILE Statement for external file with delimiters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919693#M362260</link>
    <description>&lt;P&gt;I had tried that . DSD did not help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i used the below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	INFILE 'FILE_LOCN/TEST_FILES/test.txt'
		FIRSTOBS=2
		LRECL=32767
		ENCODING="LATIN9"
		TERMSTR=CRLF
		DLM="|#"
		DSD
		MISSOVER&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Below is the output. it puts a blank into case id&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94544i8661E93AE55E3504/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Mar 2024 19:01:08 GMT</pubDate>
    <dc:creator>Anuz</dc:creator>
    <dc:date>2024-03-10T19:01:08Z</dc:date>
    <item>
      <title>INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919685#M362255</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some help with my INFILE statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an external file that has more than 500 fields.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the file has delimiter as # the below code works absolutely fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INFILE '/file_location/customer.txt'&lt;BR /&gt;FIRSTOBS=2&lt;BR /&gt;LRECL=32767&lt;BR /&gt;ENCODING="LATIN9"&lt;BR /&gt;TERMSTR=CRLF&lt;BR /&gt;DLM="#"&lt;BR /&gt;MISSOVER&lt;BR /&gt;DSD&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my file has |# as the delimiter&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INFILE '/file_location/customer.txt'&lt;BR /&gt;FIRSTOBS=2&lt;BR /&gt;LRECL=32767&lt;BR /&gt;ENCODING="LATIN9"&lt;BR /&gt;TERMSTR=CRLF&lt;BR /&gt;DLM="|#"&lt;BR /&gt;MISSOVER&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seemed to work ok.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but if there is no value between the delimiters it screws the alignment of the data to the columns&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created and attached a test file that I used.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code i used&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
LENGTH
cust_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ 500
caseId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$ 500
website&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$ 500
;
LABEL
cust_id = "CUST ID "
caseId = "CASE"
website = "website"
;
FORMAT
cust_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $CHAR500.
caseId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$CHAR500.
website&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$CHAR500.
;
INFORMAT
cust_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $CHAR500.
caseId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$CHAR500.
website&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$CHAR500.
;
INFILE '/file_locn/test.txt'
FIRSTOBS=2
LRECL=32767
ENCODING="LATIN9"
TERMSTR=CRLF
DLM="|#"
MISSOVER

;
INPUT
cust_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : $CHAR500.
caseId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: $CHAR500.
website : $CHAR500.
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please tell me what I need to correct in the code to load the file correctly with blank values when there are no values. Thank you&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 17:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919685#M362255</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-03-10T17:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919686#M362256</link>
      <description>&lt;P&gt;The DSD modifier will resolve this problem.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INFILE '/file_location/customer.txt' FIRSTOBS=2 LRECL=32767 ENCODING="LATIN9" TERMSTR=CRLF DLM="|#" DSD MISSOVER;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Mar 2024 18:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919686#M362256</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-03-10T18:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919688#M362257</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The DSD modifier will resolve this problem.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INFILE '/file_location/customer.txt' FIRSTOBS=2 LRECL=32767 ENCODING="LATIN9" TERMSTR=CRLF DLM="|#" DSD MISSOVER;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;... if, in addition, DLM= is replaced with&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#n10jzr9z76e1ghn12i7ie8514fjv" target="_blank" rel="noopener"&gt;DLMSTR=&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 18:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919688#M362257</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-03-10T18:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919693#M362260</link>
      <description>&lt;P&gt;I had tried that . DSD did not help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i used the below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	INFILE 'FILE_LOCN/TEST_FILES/test.txt'
		FIRSTOBS=2
		LRECL=32767
		ENCODING="LATIN9"
		TERMSTR=CRLF
		DLM="|#"
		DSD
		MISSOVER&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Below is the output. it puts a blank into case id&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94544i8661E93AE55E3504/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 19:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919693#M362260</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-03-10T19:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919695#M362262</link>
      <description>&lt;P&gt;That seems to have worked&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Used the below&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INFILE 'File_Locn/test.txt'
FIRSTOBS=2
LRECL=32767
ENCODING="LATIN9"
TERMSTR=CRLF
DLMSTR="|#"
DSD
MISSOVER&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That has loaded the data correctly. The key was DLMSTR. I was not aware of the same.&lt;/P&gt;
&lt;P&gt;if DLM with DSD is used it does not resolve the issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DLMSTR with DSD works.. I shall now test with the real files and fingers crossed should be ok .Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 19:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919695#M362262</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-03-10T19:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919698#M362264</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382230"&gt;@Anuz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I had tried that . DSD did not help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i used the below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	INFILE 'FILE_LOCN/TEST_FILES/test.txt'
		FIRSTOBS=2
		LRECL=32767
		ENCODING="LATIN9"
		TERMSTR=CRLF
		DLM="|#"
		DSD
		MISSOVER&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Below is the output. it puts a blank into case id&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94544i8661E93AE55E3504/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It did what you asked it to do.&amp;nbsp; Since both | and # are possible delimiter characters when they are next to each other that means there is an empty value.&amp;nbsp; You could compensate by reading those into a dummy variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test temp;
options parmcards=test;
parmcards;
cust_id|#caseId|#website
B132|#1453|#abcd@co.uk
B132|#null|#abcd@co.uk
B132|#|#abcd@co.uk
;


data test1;
  infile test dsd truncover dlm='|#' firstobs=2 ;
  input cust_id $ dummy caseid $ dummy website :$100.;
  drop dummy;
run;

data test2;
  infile test dsd truncover dlmstr='|#' firstobs=2 ;
  input cust_id $ caseid $ website :$100.;
run;

proc compare data=test1 compare=test2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS There is no need to use the ANCIENT option MISSOVER.&amp;nbsp; Use the MODERN (probably 30 years old) TRUNCOVER option instead.&amp;nbsp; Doesn't matter as long as you only use LIST MODE input, but if you slip into using FORMATTED mode or COLUMN mode input then&amp;nbsp;you have told SAS to IGNORE text at the end of the line that is shorter than the informat being used.&amp;nbsp;&amp;nbsp;&lt;/P&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>Sun, 10 Mar 2024 22:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919698#M362264</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-10T22:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE Statement for external file with delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919728#M362273</link>
      <description>Thank you Tom .. Appreciate the detail that you have shared. Really helpful.</description>
      <pubDate>Mon, 11 Mar 2024 08:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-Statement-for-external-file-with-delimiters/m-p/919728#M362273</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-03-11T08:13:00Z</dc:date>
    </item>
  </channel>
</rss>

