Help using Base SAS procedures

How to import this file to SAS

Reply
Regular Contributor
Posts: 222

How to import this file to SAS

Hello!

could anyone help me import this file into SAS?

the extension name is not .txt but it can be read by notepad,I want import this file into SAS without change its extension name(if I change .srt to .txt it will works but i want see whether we don't need to change it).

data one

infile "C:\Users\Lost - [2x07] - The Other 48 Days.XviD-LOL.English.srt;

input contens;

run;

please see attachment.

Thanks!

Mike

Attachment
Super Contributor
Posts: 297

Re: How to import this file to SAS

Posted in reply to Mike_Davis

You haven't provided any information on the desired output, so I am assuming that you just simply want it read in.

DATA WORK.Lost____2x07____The_Other_48_Day;

    LENGTH

        F1               $ 2000 ;

    FORMAT

        F1               $CHAR40. ;

    INFORMAT

        F1               $CHAR40. ;

    INFILE 'E:\Lost - [2x07] - The Other 48 Days.XviD-LOL.English.SRT'

        LRECL=2000

        TERMSTR=CRLF

        TRUNCOVER ;

    INPUT

        @1     F1               $CHAR2000. ;

RUN;

Valued Guide
Posts: 2,177

Re: How to import this file to SAS

Posted in reply to Scott_Mitchell

and if Mike just wants to view it in SAS

PROC FSLIST FILE= "that file";

RUN;

Trusted Advisor
Posts: 3,215

Re: How to import this file to SAS

Posted in reply to Mike_Davis

If you run the following code (corrected missing ") what are the messages?

The infile statement does not care for extensions. With SAS never experienced... SAS(R) 9.4 Statements: Reference

SAS(R) 9.4 Companion for Windows (infile - referencing external files)

By the way, It is really simple short ascii file with 3 record/obs (1/ recno, 2/ timing info 3/ message line(s)   segregated by blank line)

data one

infile "C:\Users\Lost - [2x07] - The Other 48 Days.XviD-LOL.English.srt" ;    /* added the quotes */

input ;  put _infile_ ;

run;

---->-- ja karman --<-----
Trusted Advisor
Posts: 1,301

Re: How to import this file to SAS

Posted in reply to Mike_Davis

As others have stated, you are missing a closing quotation mark at the end of your infile statement fileref.  The file format is also quite simple.

data subs;

infile '/path/to/file.srt' truncover ;

input #1 id

      #2 xstart_time $12. +5 xend_time $12.

   #3 sub $200.

   #4

;

format start_time end_time time12.3 ;

start_time = input( translate( xstart_time , '.' , ',' ) , time12. ) ;

end_time   = input( translate( xend_time   , '.' , ',' ) , time12. ) ;

drop xstart_time xend_time;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 289 views
  • 0 likes
  • 5 in conversation