SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

SAS macro to read multiple rawdata files and create multiple SAS dataset for each raw data file

Reply
New Contributor
Posts: 3

SAS macro to read multiple rawdata files and create multiple SAS dataset for each raw data file

Hi there

 

My name is Chandra. I am not very good at SAS macro especially the looping part and resolving &&&. etc. Here is my problem statement.

 

Problem statement:

I have large number of raw data files (.dat files) stored in a folder in a SAS server. I need a macro that can read each of these rawdata file and create SAS data set for each raw data file and store them in a separate target folder in the SAS server. All these raw data files have same file layout structure. I need to automate this operation so that every week, the macro reads raw data files from the source folder and creates the corresponding SAS dataset and stores them in the target folder in the SAS server. For example, if there are 200 raw data files in a source folder, I want to read them and create 200 SAS datasets one for each rawdata file and save them in a separate target folder. I am not very good at constructing looping statement and also resolving && or &&& etc.  How do I do it?

 

I would highly appreciate your kind assistance in this regard.

 

Respectfully

 

Chandra

 

 

Super User
Posts: 19,789

Re: SAS macro to read multiple rawdata files and create multiple SAS dataset for each raw data file

Posted in reply to u_chandra
SAS Super FREQ
Posts: 708

Re: SAS macro to read multiple rawdata files and create multiple SAS dataset for each raw data file

Posted in reply to u_chandra

Chandra

 

To get a list of files you can use this macro http://www.sascommunity.org/wiki/Filelist_macro once you have the list of files I suggest you use a pattern very well described by @ChrisHemedinger in his blog entry Implement BY processing for your entire SAS program. Well in your case it is not about BY Group processing but more like doing something over a list of values.

 

Since you need a new library for each SAS data set, have a look at the SAS trick: get the LIBNAME statement to create folders for you

 

Bruno

Super User
Posts: 5,426

Re: SAS macro to read multiple rawdata files and create multiple SAS dataset for each raw data file

Posted in reply to u_chandra
Creating 200+ files at different locations sounds like an non best practice. How do you maintain this, over time?
What is the the requirement?
Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 542 views
  • 3 likes
  • 4 in conversation