Help using Base SAS procedures

appending files in a directory

Posts: 0

appending files in a directory

Im new to sas and I need to append multiple files in a single directory into one file. Ive seen ways to append one file to another but Im curious what is needed to append multiple files that are in one directory together? Message was edited by: TDS
Super Contributor
Super Contributor
Posts: 3,174

Re: appending files in a directory

When you mention append files, one could infer that you are appending sequential files, not SAS files. You can use the SAS DATA step process combined with a FILENAME statement, in order to treat the entire set of files as one concatenated stream. With the FILENAME statement enclose the list of files in parantheses. And using the DATA step, use the INFILE and FILE statements, combined with an INPUT and PUT _INFILE_; set of statements to process your data. No SAS file is created, only your output file specified in the (output) FILE statement.

Have a look at the SAS "companion" document for your operating environment, with focus on the topics "Using External Files" and also "Concatenating Filenames". Here is a link to one reference for the UNIX environment - there are similar discussions for other environments:

Also, you will find the SAS support website has SAS product documentation and also supplemental technical (SAS staff and user community contributed) papers on this type of topic -- have a look at using the SEARCH facility or use Google (example below) to search the site for relevant material:

concatenate sequential files filename

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation