Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I import an unknown number of .txt files into SAS?

Status
Not open for further replies.

aybooth

MIS
Feb 6, 2004
9
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top