I am trying to import an unknown number of text files into SAS. I have found some codes but none seem to work...
filename indata pipe 'dir d:\requests\miller\testfiles /b';
data file_list;
length fname $20;
infile indata truncover; /* infile statement for file names */
input fname $20.; /* read the file names from the directory */
call symput ('num_files',_n_); /* store the record number in a macro variable */
run;
the pipe function does not seem to work and if I try to name the pipe my PC crashes out!
The rest of the code is...
%macro fileread;
%do j=1 %to &num_files;
data _null_;
set file_list;
if _n_=&j;
call symput ('filein',fname);
run;
data var_names;
length x1-x17 $12;
infile "d:\requests\miller\testfiles\&filein" obs=1 missover;
input (x1-x17) ($) ;
run;
%macro varnames;
%do i=1 %to 17;
%global v&i;
2
SUGI 29 Coders' Corner
data _null_;
set var_names;
call symput("v&i",trim(x&i));
run;
%end;
%mend varnames;
%varnames;
...but without the initial part I am unable to run the rest.
Thanks
filename indata pipe 'dir d:\requests\miller\testfiles /b';
data file_list;
length fname $20;
infile indata truncover; /* infile statement for file names */
input fname $20.; /* read the file names from the directory */
call symput ('num_files',_n_); /* store the record number in a macro variable */
run;
the pipe function does not seem to work and if I try to name the pipe my PC crashes out!
The rest of the code is...
%macro fileread;
%do j=1 %to &num_files;
data _null_;
set file_list;
if _n_=&j;
call symput ('filein',fname);
run;
data var_names;
length x1-x17 $12;
infile "d:\requests\miller\testfiles\&filein" obs=1 missover;
input (x1-x17) ($) ;
run;
%macro varnames;
%do i=1 %to 17;
%global v&i;
2
SUGI 29 Coders' Corner
data _null_;
set var_names;
call symput("v&i",trim(x&i));
run;
%end;
%mend varnames;
%varnames;
...but without the initial part I am unable to run the rest.
Thanks