BookmarkSubscribeRSS Feed
Solvej
Obsidian | Level 7

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

5 REPLIES 5
novinosrin
Tourmaline | Level 20

data read;
input var1 :$15. var2 &  $100.;
var1=compress(var1,,'kd');
var2=substr(var2,anyalpha(var2));
cards;
afd1301033             200001011999112425000101Hjertemedicinsk klinik B, kardiologisk laboratorium
;
PeterClemmensen
Tourmaline | Level 20

Have you read the text file in as a SAS data set already or do you need help with that as well?

Solvej
Obsidian | Level 7
I would like help with that as well. At the moment i have used infile.
PeterClemmensen
Tourmaline | Level 20

If not, do like this and use the logic provided by @novinosrin 

 

data want;
   infile "YourPathHere\textfile.txt";
   input var1 :$15. var2 &  $100.;
run;
Tom
Super User Tom
Super User

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 986 views
  • 4 likes
  • 4 in conversation