<?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: Input a text file, the output date format is missing in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773690#M31190</link>
    <description>&lt;P&gt;This is not odd or a bug, what you are doing is mixing and matching input methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input PERSON_ID $ DEPT_ID $ DATE_JOINED $10. ; * yymmdd10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So PERSON_ID &amp;amp; DEPT_ID are both considered &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_self"&gt;list input&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Whereas the DATE_JOINED is considered &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0f9yk6pd4znukn1rlw6hzkg1url.htm" target="_self"&gt;formatted input&lt;/A&gt;&amp;nbsp;as you define a format to use ($10.)&lt;BR /&gt;&lt;BR /&gt;To get the DATE_JOINED to be read correctly you need to change it to use list input, by using the : modifier and supply a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input PERSON_ID $ DEPT_ID $ : DATE_JOINED $10. ; * yymmdd10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now for the why&lt;BR /&gt;The DLM option on the INFILE statement uses any of the characters as delimiters, not the whole string. So SAS sees PERSON_ID as "AAAAA" followed by 3 delimiters "&amp;lt;", "|" &amp;amp; "&amp;gt;". The next variable is DEPT_ID "S1" at this point the line pointer is pointing at the "|" and you switch to formatted input and read the next 10 characters "|&amp;gt;2021/01/".&lt;BR /&gt;DLMSTR works because SAS sees the whole "&amp;lt;|&amp;gt;" as a single delimiter and the line pointer is now at the start of the date.&lt;BR /&gt;&lt;BR /&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 17:11:05 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2021-10-12T17:11:05Z</dc:date>
    <item>
      <title>Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773538#M31182</link>
      <description>&lt;P&gt;I have an input txt file and uploaded it to my working directory, when I read and format the DATE_JOINED column, the date is missing, code as following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data example_txt;
	infile '/home/u59667351/example_csv/example_csv.txt' dlm='&amp;lt;|&amp;gt;' firstobs=2;
	input PERSON_ID $ DEPT_ID $ DATE_JOINED yymmdd10. ;
	format DATE_JOINED yymmdd10.;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the text file named example_csv as following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PERSON_ID&amp;lt;|&amp;gt;DEPT_ID&amp;lt;|&amp;gt;DATE_JOINED&lt;BR /&gt;AAAAA&amp;lt;|&amp;gt;S1&amp;lt;|&amp;gt;2021/01/03&lt;BR /&gt;BBBBBB&amp;lt;|&amp;gt;S2&amp;lt;|&amp;gt;2021/02/03&lt;BR /&gt;CCCCC&amp;lt;|&amp;gt;S1&amp;lt;|&amp;gt;2021/03/05&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The OUTPUT date DATE_JOINED is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 03:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773538#M31182</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2021-10-12T03:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773539#M31183</link>
      <description>&lt;P&gt;When I run next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example_txt;
	infile CARDS dlm='&amp;lt;|&amp;gt;' firstobs=2;
	input PERSON_ID $ DEPT_ID $ DATE_JOINED $10.; * yymmdd10. ;
	*format DATE_JOINED yymmdd10.;
cards;
PERSON_ID&amp;lt;|&amp;gt;DEPT_ID&amp;lt;|&amp;gt;DATE_JOINED
AAAAA&amp;lt;|&amp;gt;S1&amp;lt;|&amp;gt;2021/01/03
BBBBBB&amp;lt;|&amp;gt;S2&amp;lt;|&amp;gt;2021/02/03
CCCCC&amp;lt;|&amp;gt;S1&amp;lt;|&amp;gt;2021/03/05
;
run;&amp;nbsp;proc&amp;nbsp;print;&amp;nbsp;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I got next result:&lt;/P&gt;
&lt;PRE&gt;Obs	PERSON_ID DEPT_ID  DATE_JOINED
1	AAAAA	  S1	   |&amp;gt;2021/01/
2	BBBBBB	  S2	   |&amp;gt;2021/02/
3	CCCCC	  S1	   |&amp;gt;2021/03/&lt;/PRE&gt;
&lt;P&gt;as you see sas doesn't read the&amp;nbsp;&lt;CODE class=" language-sas"&gt;DATE_JOINED correctly.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;When I change the input to a real csv (comma delimited) it works fine.&lt;/P&gt;
&lt;P&gt;There is probably a non printable character inside the last delimiter.&lt;/P&gt;
&lt;P&gt;I'm going to check it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 04:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773539#M31183</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-10-12T04:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773540#M31184</link>
      <description>&lt;P&gt;The docs of dlm/delimiter say:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;specifies one or more characters to read as delimiter&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;s&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have highlighted the important char. You need to use option dlmstr instead, because your have only one delimiter in your data, the string "&amp;lt;|&amp;gt;".&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 05:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773540#M31184</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-10-12T05:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773542#M31185</link>
      <description>&lt;P&gt;This one works. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 06:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773542#M31185</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2021-10-12T06:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773543#M31186</link>
      <description>&lt;P&gt;It works!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 06:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773543#M31186</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2021-10-12T06:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773622#M31187</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;ת, you are right that&amp;nbsp;&lt;STRONG&gt;dlmstr&lt;/STRONG&gt; solves the issue, but it is very starnge why the first two variables were read correctly and only the last variable was read incorrectly, as I show in my post of result:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;When I run next code:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data example_txt;
	infile CARDS dlm='&amp;lt;|&amp;gt;' firstobs=2;
	input PERSON_ID $ DEPT_ID $ DATE_JOINED $10.; * yymmdd10. ;
	*format DATE_JOINED yymmdd10.;
cards;
PERSON_ID&amp;lt;|&amp;gt;DEPT_ID&amp;lt;|&amp;gt;DATE_JOINED
AAAAA&amp;lt;|&amp;gt;S1&amp;lt;|&amp;gt;2021/01/03
BBBBBB&amp;lt;|&amp;gt;S2&amp;lt;|&amp;gt;2021/02/03
CCCCC&amp;lt;|&amp;gt;S1&amp;lt;|&amp;gt;2021/03/05
;
run; proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I got next result:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;Obs	PERSON_ID DEPT_ID  DATE_JOINED
1	AAAAA	  S1	   |&amp;gt;2021/01/
2	BBBBBB	  S2	   |&amp;gt;2021/02/
3	CCCCC	  S1	   |&amp;gt;2021/03/&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;It seems to be a bug ?!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 12:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773622#M31187</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-10-12T12:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773632#M31188</link>
      <description>&lt;P&gt;That is just the difference between FORMATTED input and LIST MODE input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With LIST MODE input the INPUT statement will skip over the delimiters the cursor it currently pointed at. So the extra pipe and greater than character are ignored when reading DEPT_ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the : modifier in front of any informat specifications you have included in the INPUT statement to allow the INPUT statement to work in LIST MODE instead of FORMATTED mode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input PERSON_ID $ DEPT_ID $ DATE_JOINED :yymmdd. ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 13:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773632#M31188</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-12T13:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773690#M31190</link>
      <description>&lt;P&gt;This is not odd or a bug, what you are doing is mixing and matching input methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input PERSON_ID $ DEPT_ID $ DATE_JOINED $10. ; * yymmdd10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So PERSON_ID &amp;amp; DEPT_ID are both considered &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_self"&gt;list input&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Whereas the DATE_JOINED is considered &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0f9yk6pd4znukn1rlw6hzkg1url.htm" target="_self"&gt;formatted input&lt;/A&gt;&amp;nbsp;as you define a format to use ($10.)&lt;BR /&gt;&lt;BR /&gt;To get the DATE_JOINED to be read correctly you need to change it to use list input, by using the : modifier and supply a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input PERSON_ID $ DEPT_ID $ : DATE_JOINED $10. ; * yymmdd10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now for the why&lt;BR /&gt;The DLM option on the INFILE statement uses any of the characters as delimiters, not the whole string. So SAS sees PERSON_ID as "AAAAA" followed by 3 delimiters "&amp;lt;", "|" &amp;amp; "&amp;gt;". The next variable is DEPT_ID "S1" at this point the line pointer is pointing at the "|" and you switch to formatted input and read the next 10 characters "|&amp;gt;2021/01/".&lt;BR /&gt;DLMSTR works because SAS sees the whole "&amp;lt;|&amp;gt;" as a single delimiter and the line pointer is now at the start of the date.&lt;BR /&gt;&lt;BR /&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 17:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773690#M31190</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-10-12T17:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Input a text file, the output date format is missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773929#M31199</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, it is clear now, and sorry for my late response.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Input-a-text-file-the-output-date-format-is-missing/m-p/773929#M31199</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-10-13T13:59:31Z</dc:date>
    </item>
  </channel>
</rss>

