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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.