From: maverick2 on 8 Jan 2010 17:21 I have a folder that contains 10 files of a type other than SAS. (eg EXCEL). Now I have the code for converting every single EXCEL file into SAS using a simple macro by passing the filename as a parameter. But can I read the names of these EXCEL files without having to type them out in my code? eg if all of the files were .sas7bdat, it is possible to use dictionary.tables to get the filenames, process them and do anything required without having to manually type the file names, but since these are EXCEL files, is something similar possible?
From: Tom Abernathy on 8 Jan 2010 18:14 SAS has functions to open directories and read the filenames (DOPEN, DREAD) but I usually find it much easier to use a PIPE and a dataset. For example : %let path=data_files; * PC ; filename dir pipe "dir &path /b"; * Unix ; filename dir pipe "ls -A &path"; data files; infile dir truncover; input filename $80.; if index(filename,'.') then ext=scan(filename,-1,'.'); if ext = 'xls' then call execute('%readxls(' || trim(filename) || ')' ); run; On Jan 8, 5:21 pm, maverick2 <phekuch...(a)gmail.com> wrote: > I have a folder that contains 10 files of a type other than SAS. (eg > EXCEL). Now I have the code for converting every single EXCEL file > into SAS using a simple macro by passing the filename as a parameter. > But can I read the names of these EXCEL files without having to type > them out in my code? eg if all of the files were .sas7bdat, it is > possible to use dictionary.tables to get the filenames, process them > and do anything required without having to manually type the file > names, but since these are EXCEL files, is something similar possible?
From: Savian on 8 Jan 2010 20:05 On Jan 8, 3:21 pm, maverick2 <phekuch...(a)gmail.com> wrote: > I have a folder that contains 10 files of a type other than SAS. (eg > EXCEL). Now I have the code for converting every single EXCEL file > into SAS using a simple macro by passing the filename as a parameter. > But can I read the names of these EXCEL files without having to type > them out in my code? eg if all of the files were .sas7bdat, it is > possible to use dictionary.tables to get the filenames, process them > and do anything required without having to manually type the file > names, but since these are EXCEL files, is something similar possible? I wrote a utility function that provides just about everything you can get on files and allows for wildcard searching and recursion into the directories. It is free: http://utilities.savian.net/ Look at Get File Info. Alan http://www.savian.net
From: rjf2 on 11 Jan 2010 10:04 > From: maverick2 > Sent: Friday, January 08, 2010 5:21 PM > Subject: automatically reading other formats into SAS > > I have a folder that contains 10 files of a type other than SAS. (eg > EXCEL). Now I have the code for converting every single EXCEL file > into SAS using a simple macro by passing the filename as a parameter. > But can I read the names of these EXCEL files without having to type > them out in my code? eg if all of the files were .sas7bdat, it is > possible to use dictionary.tables to get the filenames, process them > and do anything required without having to manually type the file > names, but since these are EXCEL files, is something similar possible? this page contains a section for reading a list of filenames http://www.sascommunity.org/wiki/Making_Lists Ron Fehd the module/routine/subroutine maven CDC Atlanta GA USA RJF2 at cdc dot gov
|
Pages: 1 Prev: Unable to initialize the SAS Kernal Next: Fisher's exact test appropriate here? |