<?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 Pipe delimited file with no Carriage Return and no header row of variable names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550490#M152845</link>
    <description>&lt;P&gt;1. The example provided imports fine for me using your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You could change the file using SAS code as a pre-processing step rather than doing it manually&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. An alternative is to reuse the data step created by &lt;FONT face="courier new,courier"&gt;proc import&lt;/FONT&gt; and run that instead of the proc, after adding the option &lt;FONT face="courier new,courier"&gt;termstr&lt;/FONT&gt;= .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2019 03:10:51 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-04-12T03:10:51Z</dc:date>
    <item>
      <title>Importing Pipe delimited file with no Carriage Return and no header row of variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550481#M152839</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a pipe delimited .txt file with 5000 observations and 89 variables into SAS. There are a couple of issues with this data that I am trying to work around:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Between observations, there is no space or carriage return. This means that between the value for the last variable of a particular observation and the value for the first variable of the next observation, there is no space or carriage return to indicate that what follows is a new observation. SAS does import some of the observations correctly, however, there are a few cases where SAS is unable to parse the first variable and thus returns a missing observation. &lt;STRONG&gt;Is there a way I can work around this issue without going into the text file and manually adding a carriage return?&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;There is no header line with variable names, therefore SAS imports the data with generic variable names (i.e. VAR1, VAR2, etc.). I have imported a list of variable names that I created in Excel based on a SQL query and assigned them to a macro variable. I&lt;STRONG&gt;s there a way I can use this macro variable of the variable names (with a single space between names) to assign the variable names?&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here is the code that I am trying to work with:&lt;/P&gt;&lt;PRE&gt;proc import out = data_import
	datafile = "&amp;amp;filepath/2018_JAN_5000.txt"
	dbms = DLM replace;
	delimiter = "|";
	getnames = NO;
	DATAROW = 1;
run;

proc sql;
	select sas_variable_name
	into: variable_names separated by " "
	from variable_order
	;
quit;
%put &amp;amp;variable_names.;

data data_import_2;
	set data_import;
	retain &amp;amp;variable_names.;
run;&lt;/PRE&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;ap1994&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550481#M152839</guid>
      <dc:creator>ap1994</dc:creator>
      <dc:date>2019-04-15T20:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with no Carriage Return and no header row of variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550490#M152845</link>
      <description>&lt;P&gt;1. The example provided imports fine for me using your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You could change the file using SAS code as a pre-processing step rather than doing it manually&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. An alternative is to reuse the data step created by &lt;FONT face="courier new,courier"&gt;proc import&lt;/FONT&gt; and run that instead of the proc, after adding the option &lt;FONT face="courier new,courier"&gt;termstr&lt;/FONT&gt;= .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 03:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550490#M152845</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-12T03:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with no Carriage Return and no header row of variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550496#M152849</link>
      <description>&lt;P&gt;When I review the flle you posted using this website preview function it looks like two lines of data to me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure the file is not just use LF only as the end of line (as is normal on Unix) instead of CR and LF (as it normal on Windows)?&lt;/P&gt;
&lt;P&gt;Also you still occasionally see files that use CR only as the end of line (as was used on the original Apple Mac computers before they switched MacOS to a version of Unix).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use SAS to check by reading the beginning of the file as a fixed length records.&amp;nbsp; Then the actual end of line characters will be read as part of the data and will show in the log.&amp;nbsp; This program will read the first 500 bytes of the file and dump it to the SAS log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile ""&amp;amp;filepath/2018_JAN_5000.txt" recfm=50 obs=10;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 04:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550496#M152849</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-12T04:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with no Carriage Return and no header row of variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550497#M152850</link>
      <description>&lt;P&gt;I wouldn't bother to use PROC IMPORT to read a delimited file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The shell of a program to read a delimited file can be as simple as this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "&amp;amp;filepath/2018_JAN_5000.txt" dsd dlm='|' truncover ;
  length var1 8 var2 $20 ..... var_last 8 ;
  informat datevar mmddyy.;
  format datevar date9.;
  input var1 -- var_last ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So just copy&amp;nbsp;copy the names from your sheet and paste them into your program in the LENGTH statement. Make some guesses about whether the variable is number (length of &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; or character (length starts with $).&amp;nbsp; If unsure just set it to something like $50 and check the values after you have it in a dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 04:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550497#M152850</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-12T04:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with no Carriage Return and no header row of variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550505#M152852</link>
      <description>&lt;P&gt;Just opened the file you posted with notepad++ and the file has linux/unix line breaks, so using a data step to read the file should be possible, if you add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;termstr=LF&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to the infile-statement.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; already suggested this &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 05:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/550505#M152852</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-12T05:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with no Carriage Return and no header row of variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/551233#M153141</link>
      <description>&lt;P&gt;Thanks everyone for your help! I ended up importing the file using a data step with termstr = LF as an option.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Pipe-delimited-file-with-no-Carriage-Return-and-no/m-p/551233#M153141</guid>
      <dc:creator>ap1994</dc:creator>
      <dc:date>2019-04-15T20:01:39Z</dc:date>
    </item>
  </channel>
</rss>

