Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

How to read data into SAS from some files with different names but with the similar inner structure automatically?

Reply
Contributor
Posts: 57

How to read data into SAS from some files with different names but with the similar inner structure automatically?

For example, I have the files (within the same directory) named with

human_CDx+CDx+xxh_1way_RM_ANOVA

common fragment in its names.

The inner structure of the files is as follows:

LINE with text

LINE with text

LINE with text

LINES with DATA

LINE with text

LINE with text

LINE with text

LINE with text

LINE with text

Respected Advisor
Posts: 4,663

Re: How to read data into SAS from some files with different names but with the similar inner structure automatically?

INFILE supports simple wildcard characters (both in Windows and Unix) for reading multiple files. Use filename= option to know where each observation comes from, as in

infile ('c:\myfiles\*.*','c:\myotherfiles\abc.dat') filename=whatFile;

PG

PG
Contributor
Posts: 57

Re: How to read data into SAS from some files with different names but with the similar inner structure automatically?

It works! But my intention is to make SAS compute different data sets

stored in '.txt' files located in a directory consequently. One by one.

There is an article at UCLA website:

SAS FAQ: How do I read multiple raw data files with the same structure in one data step?

But I get a big table with directories and data themselves instead of my SAS script

consecutive execusions with different data sets.

How to implement this?

Thanks for any response.

Ask a Question
Discussion stats
  • 2 replies
  • 247 views
  • 0 likes
  • 2 in conversation