Import multiple files at once

Reply
Contributor
Posts: 44

Import multiple files at once

I have around 22 files which have the below names, all i am trying to do is import these files in sas.

1974_1244444445587624_1.rpt

1974_1745888886578142_2.rpt

.

.

.

.

.

.

1974_1896547223569999_22.rpt

Please advise any thoughts.each file should create a dataset.

Valued Guide
Posts: 3,206

Re: Import multiple files at once

Use wildcards like * in the filename. Within Unix you can expand that with pattern matching.

Are these flat-files?  Using a datastep 

---->-- ja karman --<-----
Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: Import multiple files at once

One alternative is to pipe in a list of filenames, then call execute your import (note might not work out of the box as I am typing from memory):

filename pipe mylist 'dir "c:\somewhere\*.rpt" /b';

data _null_;

     length buffer $2000.;

     infile mylist dsd missover lrecl=32000;

     input buffer $;

     call execute('proc import datafile="'||strip(buffer)||'" out=work.'||strip(tranwrd(buffer,".rpt",""))||' replace;

                          run;');

run;

Respected Advisor
Posts: 3,775

Re: Import multiple files at once

What is the content of the files?  RPT suggests something other than delimited fields like CSV or TXT which may rule out PROC IMPORT.

Ask a Question
Discussion stats
  • 3 replies
  • 203 views
  • 0 likes
  • 4 in conversation