Help using Base SAS procedures

reading multiple files

Reply
N/A
Posts: 0

reading multiple files

Hi SAS users,

I have a question regarding reading multiple files. I have a folder containing 13 text files with filenames starting with a number (ex. 1.txt, 2.txt, 3.txt....) and they all have the same variables but different data values. I'd like to use the files 1 and 2, 2 and 3, 3 and 4, 4 and 5, and so forth in successive executions such that I can stack the descriptive statistics generated for 1 and 2, 2 and 3, 3 and 4....into one large file. So, each combination (eg. 1.txt, 2.txt; 2.txt, 3.txt, etc) will be given an id followed by the descriptive statistics. Can anybody offer some suggestions? Thanks!
Super User
Posts: 11,343

Re: reading multiple files

Posted in reply to deleted_user
I'd be tempted to start with a filename like:
Filename mydata '\*.txt'; /*expanding path to your location and the appropriate wildcard for your system. This will attempt to read ALL files with TXT extension in the location. */

Then in the data step have :
LENGHT FILEVARNAME $ 80 ; /*long enough to include entire path and file names above. */
and add the option FILENAME= Filevarname on the INFILE statement used to read the data.

This reads all of the text data files with a temporary variable that is not added to your data named FILEVARNAME (or what ever you'd like to call it) that can then be parsed using string functions to identify your original files and add additional variables describing the groups you want to look at later. With out knowing which summary statistics you want cant go much further but CLASS statements in PROC SUMMARY with attention to _type_ in output might get you started.
N/A
Posts: 0

Re: reading multiple files

Thanks much ballardw.
Ask a Question
Discussion stats
  • 2 replies
  • 94 views
  • 0 likes
  • 2 in conversation