LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 26 Nov 2002 10:26:59 +0100
Reply-To:   Sieto Verver <sieto@RIVO.DLO.NL>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Sieto Verver <sieto@RIVO.DLO.NL>
Subject:   Re: read all files in a directory ALL READY SOLVED

Thanks for the help Jim. My problem is solved now.

All the best Sieto

"Sieto Verver" <sieto@rivo.dlo.nl> wrote in message news:3de32684$1@news.wau.nl... > I want SAS to read all files in a directory. All the files have different > names, so I can't specify them directly in a macro. > > So far I got this code: > > >>>>>>>>>>>>>>>>>>>>>>> > %MACRO readfile (fname, file2read, setname); > DATA &setname.; > INFILE "&file2read"; > INPUT test $; > RUN; > > PROC PRINT DATA=_LAST_; RUN; > %MEND readfile; > > %MACRO readdir(dir=); > DATA temp; > rc = FILENAME("datadir","&dir."); > did = DOPEN("datadir"); > doption = DOPTNAME(did,1); > dirname = DINFO (did,doption); > memcount = DNUM (did); > > DO i = 1 TO memcount; > fname = DREAD(did, i); > fname = COMPRESS (fname," "); > file2read = TRIM(dirname) || "\" || fname; > setname=COMPRESS(fname,"."); > IF SUBSTR(fname,1,7) NE "" THEN OUTPUT; > END; > > rc = DCLOSE (did); > KEEP memcount setname fname dirname; > RUN; > > PROC PRINT DATA=_LAST_; RUN; > > > %MEND; > > %readdir(dir=~sieto/projecten/conv_snij/testset/); > >>>>>>>>>>>>>>>> > > The macro readdir produces a dataset that contains memcount (number of files > in the directory ~sieto/projecten/conv_snij/testset/ ), setname (name I want > to give to future dataset), fname (name of the file to read), file2read > (filename including path). So far so good. But now I want to use this data > to run the macro readfile and use the data to produce the macrovariables > needed in readfile. I tried to use CALL SYMPUT, but this only assigns a > macrovariable directly after submitting the programm i.s.o. after every > iteration of the macro. Anyone who has an idea? > > Thanks, > Sieto > >


Back to: Top of message | Previous page | Main SAS-L page