BookmarkSubscribeRSS Feed
dio
Calcite | Level 5 dio
Calcite | Level 5

Hello all,

i have a .txt document with several million lines and I need to create a separate text files for each of these lines of text. So, the point is to end up with several million files, each containing one line of text, in a folder named Texts. Anyone have an idea how do this?

Thanks,

Dan

2 REPLIES 2
data_null__
Jade | Level 19

I'm not sure this is a good idea.

data _null_;

   if _n_ eq 1 then rc = DCREATE('Texts','.');

   infile cards;

   input;

   filename = cats('.\texts\temp',put(_n_,z12.),'.txt');

   file dummy filevar=filename;

   put _infile_;

   cards4;

Hello all,

i have a .txt document with several million lines and

I need to create a separate text files for each of these

lines of text. So, the point is to end up with several

million files, each containing one line of text, in a

folder named Texts. Anyone have an idea how do this?

Thanks,

Dan

;;;;

   run;

art297
Opal | Level 21

DN: Yes, I;m about 2 months late responding to this, but I am playing around with SAS text miner this afternoon, trying to analyze a bunch of emails, and its instructions suggest it is best to start with separate files for each email.  I had created a SAS file containing all of the relevant info, but now am going to try it with separate txt files for each email.  The code you suggested, in response to the OP's request, will be quite helpful.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1129 views
  • 0 likes
  • 3 in conversation