Hello
How can in read in the following text file easily.
The text files are structured the following way.
afd1301033 200001011999112425000101Hjertemedicinsk klinik B, kardiologisk laboratorium
I'm only interesseret in part of the lines marked by bold. I have tousands of linies.
Kind regards
Solvej
data read;
input var1 :$15. var2 & $100.;
var1=compress(var1,,'kd');
var2=substr(var2,anyalpha(var2));
cards;
afd1301033 200001011999112425000101Hjertemedicinsk klinik B, kardiologisk laboratorium
;
Have you read the text file in as a SAS data set already or do you need help with that as well?
If not, do like this and use the logic provided by @novinosrin
data want;
infile "YourPathHere\textfile.txt";
input var1 :$15. var2 & $100.;
run;
Are you asking how to read specific columns from the line of text?
Or does the position of the strings you want vary from line to line?
Post a few lines that demonstrate the pattern. Use the Insert Code icon (looks like {i}) so that formatting is preserved.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.