Here is the step:
data _null_;
infile original dsd truncover lrecl=32767;
file fixed lrecl=1000000;
input line :$char32767. ;
if notdigit(scan(line,1,','))
and length(scan(line,1,','))>12 then put '|' @;
else put;
len=lengthn(line);
put line $varying32767. len @;
run;
The IF/THEN/ELSE is what is deciding whether or not to write an end of line. When the condition is true it writes the | without writing an end of line. Otherwise it writes just the end of line. Then it writes the current line it just read, but without an end of line. The trailing at sign on the PUT statement is what stops it from writing the end of line. Note that the last line written by a data step will automatically get an end of line added.
The test in the IF statement is checking whether the beginning of the current line (up to the first comma) does NOT look like a valid value for your first column. This is the most likely place where you might need to adjust the logic for a different version of the file.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.