BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bh11
Calcite | Level 5

Hi.  I am attempting to use the methods outlined in this blog post:

 

https://blogs.sas.com/content/sasdummy/2018/10/09/read-multiple-text-files/

 

to import multiple text files from a folder using a wildcard.

 

- Example Code from Blog Post Above -

data accel;
  infile "/home/chris.hemedinger/tsv/*.tsv" 
   dlm='09'x;
  length counter 8 
         timestamp 8 
         x 8 y 8 z 8 
         filename $ 25;
  input counter timestamp x y z filename;
run;

 

However, each of my files has field names in the first row and it appears that including the firstobs=2 option only applies to the first file contained in the folder.  As a result, SAS is attempting to read in the first row of all my datasets (minus the first dataset) as data and I am getting a lot of messages in the log about invalid data. 

 

At this point, I have included a conditional statement to later delete these unwanted rows.  This method works, but I was wondering if there is a better method that communicates to SAS to skip the first row of every dataset it is attempting to read in.  

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You need to modify your INPUT statement slightly and you can use EOV/EOF (end of variable or end of file) to indicate the end of a file. See this skeleton code here: https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-tex...

View solution in original post

1 REPLY 1
Reeza
Super User
You need to modify your INPUT statement slightly and you can use EOV/EOF (end of variable or end of file) to indicate the end of a file. See this skeleton code here: https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-tex...

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 750 views
  • 1 like
  • 2 in conversation