03-05-2013 06:36 PM
I would like to read in multiple data into SAS.
But the problem is that.. my data has no extension
(eg. drug_15_16, gorc_15_16), so I can only use infile statement to read them into SAS.
I already have a macro for reading multiple files into SAS, but it uses proc import statement.
So I need to change some parts of the macro.
Could you help me with this?
(I am using Linux operating system)
%do j=9 %to 10;
filename dir pipe "ls &subdir/*.dat";
infile dir truncover end=last expandtabs ;
input filename : $100. @@;
if last then call symputx('nobs',_n_);
%do i=1 %to &nobs;
proc import datafile="&&path&i" out=&&dsn&i dbms=csv replace;
The infile statement is..
infile "path/filenema" firstbos=2;
input v1 v2 v3 v4 v6;
I am struggling with this code for almost one week..
so any advice would be really appreciated!
03-05-2013 09:18 PM
Its rare to have files without extensions, but assuming its true, you could read all the file names in and then parse out only the ones you want.
Feed that to your input statement or proc import instead.
This doc shows how to create the file list in a dataset and read them in using a macro loop.