Hello there,
you could make the approach to read in line by line and then decide, what you want to do with your line.
Like so:
/* dummy code */ Data Work.Test (drop=help);
Length var1 var2 var3 help $50; Retain var1 var2 var3 help;
Input;
If ( countw(_infile_,"|") = 3 ) Then Do; Output; /* output previous line */
var1 = scan(_infile_,1,"|");
var2 = input(scan(_infile_,2,"|"),??best.); help = var2;
var3 = scan(_infile_,3,"|");
End; Else Do; var2 = cat(var2, _infile_); End;
Run;
I think you get the idea. Read in the line and if you have the desired number of separators, you can read in all variables with scan.
Now for the lines where you have no "|" , you should take this part and add it to the variable in the previous row.
Please note that this is just an example code above.
This leaves some questions, like what to do if another variable gets too long and cut of and you might find a number of separators ,that you do not expect, etc. etc.
This link might also help.
It all has to to with checking the line and then deciding what to do with the content 😉
Cheers,
Michael
... View more