Help using Base SAS procedures

How do I read multiple raw data files with different structure in one data step

Accepted Solution Solved
Reply
Occasional Contributor Aj
Occasional Contributor
Posts: 12
Accepted Solution

How do I read multiple raw data files with different structure in one data step

1, I have multiple unstructured log files with different formats/Type of file i.e,  : .log, .GTI, .txt files 

2. I want to read them all into a single data step    eg: file1.log, file2.GT1, file3.txt into a single data set. 

3. I tried to import them using "infile 'C:filepath\*.log" but I will be missing the files from other formats. Is there a way to upload all of them at once? 


Accepted Solutions
Solution
‎02-09-2016 09:09 AM
Super User
Posts: 10,550

Re: How do I read multiple raw data files with different structure in one data step

If you want to ALL files in the directory then 'C:\path\*.*' if just the explicit extenstions then place the diffent file name bits within parentheses and use quotes such as

infile ('C:\path\*.log' 'C:\path\*.gti' 'c:\path\*.txt')

 

When getting something a bit off like this I tend to use a FILENAME statement to create a reference to my input files as then any of the actua INFILE options are easier to find.

 

View solution in original post


All Replies
Solution
‎02-09-2016 09:09 AM
Super User
Posts: 10,550

Re: How do I read multiple raw data files with different structure in one data step

If you want to ALL files in the directory then 'C:\path\*.*' if just the explicit extenstions then place the diffent file name bits within parentheses and use quotes such as

infile ('C:\path\*.log' 'C:\path\*.gti' 'c:\path\*.txt')

 

When getting something a bit off like this I tend to use a FILENAME statement to create a reference to my input files as then any of the actua INFILE options are easier to find.

 

Trusted Advisor
Posts: 1,115

Re: How do I read multiple raw data files with different structure in one data step

I think, the INFILE statement (unlike the FILENAME statement) requires additional quotes around the parenthesized list:

infile "('C:\path\*.log' 'C:\path\*.gti' 'c:\path\*.txt')";

Occasional Contributor Aj
Occasional Contributor
Posts: 12

Re: How do I read multiple raw data files with different structure in one data step

This worked for me too. Thank you very much
Occasional Contributor Aj
Occasional Contributor
Posts: 12

Re: How do I read multiple raw data files with different structure in one data step

Thanks ballard. I used the filename to get the names of all the files I imported.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 305 views
  • 1 like
  • 3 in conversation