Folks, I have multiple files in a directory containing descriptive text. I want to read each file completely into a SAS dataset as variables with the filename in one column and the entire text from each file as the second variable. There should be as many rows in the output dataset as files in the directory. I followed Chris H.'s blog https://blogs.sas.com/content/sasdummy/2016/07/12/how-to-read-the-contents-of-a-file-into-a-sas-macro-variable/ and set the code as follows: %macro fileread; /* run this macro for each file in the directory*/ data null; length filecontent $1000 textcontent $32627 ; retain filecontent ''; infile "C:\ContestTextfile\&filein..txt" dlmstr='//' flowover end=last; %if _n_ = 1 %then input filecontent; %else %do; input; %let filecontent=cats(filecontent,_infile_); %end; if last then call symput('textcontent', filecontent); run; %mend fileread; /* the data step below uses the file list in the directory to assign each file name to a macro variable */ data htmdata.accel (keep=fname filecontent); set htmdata.file_list; length filecontent $32627 ; call symput('filein', trim(fname)); /* put the file name from the file list in a macro variable */ %fileread; /* run the macro for each file in the file list */ %let filecontent = textcontent; run; What I want is two columns in the dataset: File_Name File_Content. However, I get multiple errors with the above code: 1) both filecontent and textcontent are uninitialized; 2) the output file htmdata.accel contains only fname which was read from the file_list dataset. Any help would appreciated. Thanks! Nirup
... View more