The macro reads data from external files identified by the filerefs passed as parameters ('fileRefs' argument).
1 Code Block
DATA STEP
Explanation : Macro definition. It loops through the list of 'fileRefs', checks their existence via %sysfunc(fileref(...)), then executes a DATA STEP _NULL_ to read the file content (infile) and write it to the log (put).
Copied!
%macro dsc_echofile_tolog(fileRefs=);
/* echo the file contents to log if file exists */
%if %length(&fileRefs) > 0 %then
%do;
%let i=1;
%do %while (%scan(&fileRefs,&i,' ') ne );
%let fileRef=%scan(&fileRefs,&i);
/* if the fileref & its associated file exists? */
%if %sysfunc(fileref(&fileRef)) = 0 %then
%do;
data _null_;
length linetxt $32767;
if _n_ = 1 then
do;
/* fileHeader=sasmsg("&msg_dset","_cxa_norm_19_note","noquote","&fileRef");*/
/* put fileHeader;*/
end;
infile &fileRef. length=reclen ;
input linetxt $varying32767. reclen ;
put linetxt;
run;
%end;
%let i=%eval(&i+1);
%end;/* %do %while */
%end;/*%if %length(&fileRefs)*/
%mend;
1
%macro dsc_echofile_tolog(fileRefs=);
2
3
/* echo the file contents to log if file exists */
4
%IF %LENGTH(&fileRefs) > 0 %THEN
5
%DO;
6
%let i=1;
7
%DO %while (%scan(&fileRefs,&i,' ') ne );
8
%let fileRef=%scan(&fileRefs,&i);
9
/* if the fileref & its associated file exists? */
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright 2020, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.