<?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 can I simultaneously read in multiple text files each with a different number of columns? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570864#M17494</link>
    <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you once again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code works for one file that I read in as a test. But I noticed a problem that I was previously unaware of. Some of my data utilizes scientific notation, such as the following 1.55042962215361e-05, whereas other other data in the same file, the majority of the data, are expressed purely numerically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once imported, cells are left empty, and some data is scrambled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jul 2019 09:24:03 GMT</pubDate>
    <dc:creator>USCSS_Nostromo</dc:creator>
    <dc:date>2019-07-03T09:24:03Z</dc:date>
    <item>
      <title>How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570661#M17485</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to simultaneously read in multiple text files, each of which has a different number of columns, and create a single data set in SAS. Please see the attached example data. The data is space delimited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All of the files in the folder have the same file ending and suffix. The following code allows me to import all the text files when the total number of columns is known. In the case of my example code, it is 16 columns. Unfortunately, my data no longer has a known number of columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create columns and variables that include information included in the file name. I have been successful with this. Please have a look at the code here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am operating SAS version 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data MyData;&lt;/P&gt;&lt;P&gt;length filename fname $254;&lt;BR /&gt;infile 'C:\RES999_BNR*.TXT' dlm=' ' filename=fname firstobs=2 ;&lt;/P&gt;&lt;P&gt;filename=scan(fname,-2,'./\');&lt;BR /&gt;ID =scan(filename,1,'_','m');&lt;BR /&gt;Night =scan(filename,2,'_');&lt;/P&gt;&lt;P&gt;length var1-var16 $ 16.;&lt;BR /&gt;input var1$ var2-var16;&lt;BR /&gt;spectra = dequote(var1);&lt;BR /&gt;&lt;BR /&gt;drop var1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 17:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570661#M17485</guid>
      <dc:creator>USCSS_Nostromo</dc:creator>
      <dc:date>2019-07-02T17:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570666#M17486</link>
      <description>What do you mean when they don't all have the same amount of columns? For the missing columns, are they all at the end or can the order vary as well. Are the columns missing entirely?&lt;BR /&gt;&lt;BR /&gt;How do you read a single file right now?</description>
      <pubDate>Tue, 02 Jul 2019 17:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570666#M17486</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-02T17:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570671#M17487</link>
      <description>&lt;P&gt;The posted code will not work properly if the files have headers. You skip the header line on the first file but not the later files.&lt;/P&gt;
&lt;P&gt;It also will not work properly if they don't have headers, since then skipping the first line misses one line of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to explain how the number of columns varies to see if there is a solution.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 17:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570671#M17487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-02T17:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570681#M17488</link>
      <description>&lt;P&gt;Here's a code snippet that should help you with the issue of getting the variable number of columns into variables. Note that the first data step is just to create some text data to test on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	file "C:\some file.txt";
	Rec = "abc 123 456 789 012 345 678 901 123 456 789 012 345 678 901 345"; put Rec;
	Rec = "def 123 456 789 012 345 678 901 123 456 789 012 345 678 901 345"; put Rec;
	Rec = "ghi 123 456 789 012 345 678 901 123 456 789 012 345 678 901 345"; put Rec;
	Rec = "jkl 123 456 789 012 345 678 901 123 456 789 012 345 678 901 345"; put Rec;
run;

data MyData(drop=_:);
	infile C:\some file.txt';
	length _InRec $32767;
	length var01-var50 $ 16.;
	array _RecVars{50} var01-var50;
	input;
	_InRec = _infile_;
	_VarCount = countw(_InRec, " ");

	do _i = 1 to _VarCount;
		_RecVars{_i} = scan(_InRec, _i, " ");
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 18:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570681#M17488</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-07-02T18:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570864#M17494</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you once again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code works for one file that I read in as a test. But I noticed a problem that I was previously unaware of. Some of my data utilizes scientific notation, such as the following 1.55042962215361e-05, whereas other other data in the same file, the majority of the data, are expressed purely numerically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once imported, cells are left empty, and some data is scrambled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 09:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570864#M17494</guid>
      <dc:creator>USCSS_Nostromo</dc:creator>
      <dc:date>2019-07-03T09:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570867#M17495</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data are from EEG recordings of varying lengths. The length of the recording determines how many columns will be present in a given data set. There are always 321 rows of data. I don't need the header with the X prefixes. All subsequent rows and columns I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 09:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570867#M17495</guid>
      <dc:creator>USCSS_Nostromo</dc:creator>
      <dc:date>2019-07-03T09:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570944#M17498</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228331"&gt;@USCSS_Nostromo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data are from EEG recordings of varying lengths. The length of the recording determines how many columns will be present in a given data set. There are always 321 rows of data. I don't need the header with the X prefixes. All subsequent rows and columns I need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Ian&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should have included that detail in the original posting.&amp;nbsp; So instead of mixed number of totally &lt;STRONG&gt;different&lt;/STRONG&gt; variables you have a varying number of &lt;STRONG&gt;repeats&lt;/STRONG&gt; of the same variable.&amp;nbsp; Personally I would read the data into a tall format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the data contain any missing values in the middle of a line of values?&amp;nbsp; If not you can just loop until you read a missing value.&lt;/P&gt;
&lt;P&gt;So let's assume the files all have a header row (that you want to ignore) and that also have a first column with some information that identifies the row.&amp;nbsp; So first read that row id value and then loop reading one value at a time from the row.&lt;/P&gt;
&lt;P&gt;So something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   length fname filename $200 ;
   infile 'myfiles*.txt' dsd truncover filevar=fname ;
   input rowid $ @ ;
   if fname ne lag(fname) then delete;
   filename=fname;
   do col=1 by 1 until(value=.);
     input value @ ;
     if col=1 or value ne . then output;
   end;
run;
     &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there can be misisng values in the middle of the row then there are other ways to stop the DO loop.&amp;nbsp; You could count the number of values in the row by looking at the automatic variable _INFILE_.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do col=1 to countw(_infile_,',')-1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the line length for any row is ever greater than 32K bytes then there are ways using the LENGTH= and COL= options on the INFILE statement to detect when you have reached the end of a line.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 12:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570944#M17498</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-03T12:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570945#M17499</link>
      <description>&lt;P&gt;SAS will read a value like&amp;nbsp;&lt;SPAN&gt;1.55042962215361e-05 as a number.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Show the code and an example line of data that it is having trouble with.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570945#M17499</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-03T13:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570949#M17501</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228331"&gt;@USCSS_Nostromo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can likely get what you need by choosing suitable informats and formats.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  attrib myvar informat=best32. format=best32.;
  input myvar;
  datalines;
1.55042962215361e-05
1.5
2
;
proc print data=test;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 174px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30725i930BB914DB574DE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/570949#M17501</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-07-03T13:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/571207#M17517</link>
      <description>Hi Tom,&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply.&lt;BR /&gt;&lt;BR /&gt;I ran the code and received this error message. What is your opinion?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;13&lt;BR /&gt;14 data want ;&lt;BR /&gt;15 length fname filename $200 ;&lt;BR /&gt;16 infile 'C:\RES*.TXT' dsd&lt;BR /&gt;16 ! truncover filevar=fname ;&lt;BR /&gt;ERROR: A Physical file reference (i.e. "PHYSICAL FILE REFERENCE" ) or an aggregate file storage&lt;BR /&gt;reference (i.e. AGGREGATE(MEMBER) ) reference cannot be used with the FILEVAR= option.&lt;BR /&gt;17 input rowid $ @ ;&lt;BR /&gt;18 if fname ne lag(fname) then delete;&lt;BR /&gt;19 filename=fname;&lt;BR /&gt;20 do col=1 by 1 until(value=.);&lt;BR /&gt;21 input value @ ;&lt;BR /&gt;22 if col=1 or value ne . then output;&lt;BR /&gt;23 end;&lt;BR /&gt;24 run;&lt;BR /&gt;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 4 variables.&lt;BR /&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jul 2019 10:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/571207#M17517</guid>
      <dc:creator>USCSS_Nostromo</dc:creator>
      <dc:date>2019-07-04T10:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/571238#M17519</link>
      <description>Need the FILENAME= option instead of the FILEVAR= option.&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jul 2019 14:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/571238#M17519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-04T14:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/571262#M17520</link>
      <description>&lt;P&gt;I've modified it to input the number using the BEST format. See if this advances your progress.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	file "C:\Some file.txt";
	Rec = "abc 123 456 789 012 345 678 901 1.55042962215361e-05 456 789 012 345 678 901 345"; put Rec;
	Rec = "def 123 456 789 012 345 678 901 123 456 789 012 345 1.55042962215361e5 901 345"; put Rec;
	Rec = "ghi 123 456 789 -1.55042962215361e-05 345 678 901 123 456 789 012 345 678 901 345"; put Rec;
	Rec = "jkl 123 456 789 012 345 678 901 123 456 -1.55042962215361e05 012 345 678 901 345"; put Rec;
run;

data MyData(drop=_:);
	infile "C:\Some file.txt";
	length _InRec $32767;
	length var01-var50 8;
	array _RecVars{50} var01-var50;
	input;
	_InRec = _infile_;
	_VarCount = countw(_InRec, " ");

	do _i = 1 to _VarCount;
		_RecVars{_i} = input(scan(_InRec, _i, " "), best32.);
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jul 2019 16:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/571262#M17520</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-07-04T16:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/572003#M17561</link>
      <description>Thank you for this. I have a quick question regarding these lines of code:&lt;BR /&gt;&lt;BR /&gt;length var01-var50 8;&lt;BR /&gt;array _RecVars{50} var01-var50;&lt;BR /&gt;&lt;BR /&gt;Is it necessary that I specify a finite range of variables in that array? Because each of my files has a different number of variables. I increased to 2000 variables and received this error message:&lt;BR /&gt;&lt;BR /&gt;NOTE: 1 record was read from the infile "P:\PTSD\4. Data\EEG\EEG&lt;BR /&gt;revision\power_spectra\txtfiles_with_scoring\Test\RES*.TXT".&lt;BR /&gt;The minimum record length was 16196.&lt;BR /&gt;The maximum record length was 16196.&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following places. The results of the&lt;BR /&gt;operations have been set to missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;2001 at 63:24&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.MYDATA may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 2000 variables.&lt;BR /&gt;WARNING: Data set WORK.MYDATA was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.39 seconds&lt;BR /&gt;cpu time 0.36 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Do you have any advice on how to proceed?</description>
      <pubDate>Tue, 09 Jul 2019 11:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/572003#M17561</guid>
      <dc:creator>USCSS_Nostromo</dc:creator>
      <dc:date>2019-07-09T11:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/572014#M17562</link>
      <description>&lt;P&gt;Not sure why you are making the array, but if you are concerned it will not be large enough then just make it larger than you expect to need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You haven't shown enough of the log to see what error you are having.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you need to use one of the Insert Code buttons in the editor when pasting in log so that formatting is not removed.&lt;/P&gt;
&lt;P&gt;In general notes about missing values will not cause a data step to stop.&lt;/P&gt;
&lt;P&gt;I am a little concerned that your min and max record lengths are the same. That is not normal in a delimited text file, but perhaps it is just a side effect of stopping the data step early. Perhaps it only read in one line.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 12:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/572014#M17562</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-09T12:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simultaneously read in multiple text files each with a different number of columns?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/572221#M17565</link>
      <description>&lt;P&gt;If the problem is that there are more than 50 occurrences, a prior step to count the max number of occurrences should fix you up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	file "C:\Some file.txt";
	Rec = "987 123 456 789 012 345 678 901 1.55042962215361e-05 456 789 012 345 678 901 345"; put Rec;
	Rec = "654 123 456 789 012 345 678 901 123 456 789 012 345 1.55042962215361e5 901 345"; put Rec;
	Rec = "321 123 456 789 -1.55042962215361e-05 345 678 901 123 456 789 012 345 678 901 345"; put Rec;
	Rec = "098 123 456 789 012 345 678 901 123 456 -1.55042962215361e05 012 345 678 901 345"; put Rec;
run;

data _null_;
	retain _MaxVarCount 0;
	infile "C:\Some file.txt" end=_LastRec;
	input;
	_VarCount = countw(_infile_, " ");

	if _VarCount &amp;gt; _MaxVarCount then
		_MaxVarCount = _VarCount;

	if _LastRec then
		call symput("VarCount", strip(put(_VarCount, best15.)));
run;

data MyData(drop=_:);
	infile "C:\Some file.txt";
	length _InRec $32767;
	length var01-var&amp;amp;VarCount. 8;
	array _RecVars{&amp;amp;VarCount.} var01-var&amp;amp;VarCount.;
	input;
	_InRec = _infile_;
	_VarCount = countw(_InRec, " ");

	do _i = 1 to _VarCount;
		_RecVars{_i} = input(scan(_InRec, _i, " "), best32.);
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 19:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-I-simultaneously-read-in-multiple-text-files-each-with-a/m-p/572221#M17565</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-07-09T19:24:42Z</dc:date>
    </item>
  </channel>
</rss>

