I found some code that updates some external text files I have that issues with line feeds, and the code fixes the issue, but I have lots of files, is there a way to adapt this to fix multiple files so they can import properly? I tried using the dummy/filevar option with a dataset that has my files listed code that work for one file
%let repA='@';
%let repD='$';
data _null_;
infile &dsnnme recfm=n sharebuffers;
file &dsnnme recfm=n;
retain open 0;
input a $char1.;
if a = '"' then open = ^(open);
if open then do;
if a = '0D'x then put &repD;
else if a = '0A'x then put &repA;
end;
run;
Tried this but can't get it to work.
%let repA='@';
%let repD='$';
data _null_;
set WORK.NEW_FILES;
location=cats("mnt/ERM/Shared Services/SAS_Datasets/tempfiles/", FILE_NAME);
infile dummy filevar=location end=done recfm=n sharebuffers;
file location recfm=n;
do while(not done);
retain open 0;
input a $char1.;
if a = '"' then open = ^(open);
if open then do;
if a = '0D'x then put &repD;
else if a = '0A'x then put &repA;
end;
end;
run;
Don't you want to use option TERMSTR= to read your files instead of rewriting them?
Thanks Chris, I've tried the termstr=LF as well as cr, crlf and every combo of scanover, truncover etc and it still doesn't read the data in properly, the issue I have is an unexpected LF in the middle of quoted data, so the full line is not read in for the record and instead the rest of the data is read in as another record. Is there another way to deal with issues like this, I would love to not have to rewrite the files. thanks
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.