BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

My requirement is to read the .txt file which has filenames as follows. Now I need to read all these files to produce a master datset. All these files has a same layout.

 

SASApp_STPServer_2015-09-13_cmsaslva2_19142.log

SASApp_STPServer_2015-09-13_cmsaslva2_19143.log

SASApp_STPServer_2015-09-13_cmsaslva2_19144.log

 

I was trying to read all these filas as below code,but this code is not working as I excepted.Because only 1 record from each infile read instead of reading all the records.

 

I'm not sure for this strange behaviour.Please guide me.

 

DATA output_data_set;
/* read the file references in variable called file_names */
INFILE  '/temp/test/inputfile_txt' dsd truncover FILEVAR = file_names END = end_of_file LRECL=32000;
     DO WHILE (end_of_file = 0);
        input var : $ 3000.;
/*filename=file_names;*/
var1 = _infile_;
if var1 = :'201';
Date_TimeStamp= scan(var1,1," ");
Status = scan(var1,2," ");
Processid = scan(var1,3," ");
userid = scan(var1,4," ");
Details = scan(var1,-1,'-');
drop var var1;
        OUTPUT;
     END;
RUN;

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

This seems to very simliar to this question:

https://communities.sas.com/t5/Base-SAS-Programming/Read-the-file-names-and-create-a-dataset/m-p/225...

 

I have responded there (however am struggling to use the new forum, and can't see that response).

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 564 views
  • 0 likes
  • 2 in conversation