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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.