Help using Base SAS procedures

Creating different text documents for each line of text in a file?

Reply
Occasional Contributor dio
Occasional Contributor
Posts: 8

Creating different text documents for each line of text in a file?

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

Respected Advisor
Posts: 3,799

Re: Creating different text documents for each line of text in a file?

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;

PROC Star
Posts: 7,491

Re: Creating different text documents for each line of text in a file?

Posted in reply to data_null__

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.

Ask a Question
Discussion stats
  • 2 replies
  • 195 views
  • 0 likes
  • 3 in conversation