BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ahsan
Calcite | Level 5

Hi,

 

I try to use infile statement here is my code but I got this error message

 

DATA test;

LENGTH

'EFF DTE'n 8

COMP 8

ACCOUNT 8

'ACCOUNT DESCRIPTION'n $ 24

CENTER 8

'DOC ID'n $ 12

LINE 8

'INV.DTE'n 8

ENTY $ 4

'TXN DESCRIPTION'n $ 21

'CHECK NUM'n 8

'CTRL D GRP'n 8

AMOUNT 8

SY $ 2

'VENDOR N.'n 8

GR 8

BUYR $ 4

'PO NUMBER'n $ 10 ;

FORMAT

'EFF DTE'n MMDDYY10.

COMP BEST4.

ACCOUNT BEST6.

'ACCOUNT DESCRIPTION'n $CHAR24.

CENTER BEST8.

'DOC ID'n $CHAR12.

LINE BEST4.

'INV.DTE'n MMDDYY10.

ENTY $CHAR4.

'TXN DESCRIPTION'n $CHAR21.

'CHECK NUM'n BEST11.

'CTRL D GRP'n BEST11.

AMOUNT BEST5.

SY $CHAR2.

'VENDOR N.'n BEST9.

GR BEST2.

BUYR $CHAR4.

'PO NUMBER'n $CHAR10. ;

INFORMAT

'EFF DTE'n MMDDYY10.

COMP BEST4.

ACCOUNT BEST6.

'ACCOUNT DESCRIPTION'n $CHAR24.

CENTER BEST8.

'DOC ID'n $CHAR12.

LINE BEST4.

'INV.DTE'n MMDDYY10.

ENTY $CHAR4.

'TXN DESCRIPTION'n $CHAR21.

'CHECK NUM'n BEST11.

'CTRL D GRP'n BEST11.

AMOUNT BEST5.

SY $CHAR2.

'VENDOR N.'n BEST9.

GR BEST2.

BUYR $CHAR4.

'PO NUMBER'n $CHAR10. ;

INFILE 'H:\TEST_INFILE\OIA_EXCEL.txt'

LRECL=170

ENCODING="WLATIN1"

TERMSTR=CRLF

DLM='7F'x

MISSOVER

DSD ;

INPUT

'EFF DTE'n : ?? MMDDYY8.

COMP : ?? BEST4.

ACCOUNT : ?? BEST6.

'ACCOUNT DESCRIPTION'n : $CHAR24.

CENTER : ?? BEST8.

'DOC ID'n : $CHAR12.

LINE : ?? BEST4.

'INV.DTE'n : ?? MMDDYY8.

ENTY : $CHAR4.

'TXN DESCRIPTION'n : $CHAR21.

'CHECK NUM'n : ?? BEST11.

'CTRL D GRP'n : ?? BEST11.

AMOUNT : ?? COMMA5.

SY : $CHAR2.

'VENDOR N.'n : ?? BEST9.

GR : ?? BEST2.

BUYR : $CHAR4.

'PO NUMBER'n : $CHAR10. ;

RUN;

 

That's the error message

 

ERROR: Physical file does not exist, H:\TEST_INFILE\OIA_EXCEL.txt.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 18 variables.

WARNING: Data set WORK.TEST was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

real time 0.23 seconds

cpu time 0.07 seconds

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

The one other caveat: Did EG transform your file at all before it uploaded it?  

 

Background info in this article -- why it happens and how to make EG skip that step, which would be important for repeatability of your program.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

21 REPLIES 21
Reeza
Super User

 

ERROR: Physical file does not exist, H:\TEST_INFILE\OIA_EXCEL.txt.

 

Is the file in that location? 
Navigate to the location and right click the file while holding down the ALT button. Select Copy as Path and use that path in your code.

Tom
Super User Tom
Super User

The error message seems pretty clear. You have either typed the location of the file wrong, or the system where SAS is running cannot access that location.  Are you running SAS on a server?  Via Enterprise Guide or SAS/Studio interface perhaps?

 

But why did you attach all of those informats?  And why did you specify them twice, both with an INFORMAT statement and in-line in the INPUT statement?  

 

Note that SAS already knows how to read numbers and character strings.  Unlike with formats there is no actual informat named BEST, If you as for it SAS will simple use the normal numeric informat.  In some ways COMMA is a better informat to use as the "BEST" informat since it will recognize more strings that humans would classify as numbers.  Also the only impact of adding the $CHAR informat will be to preserve leading spaces.  Does your data file even have any values with leading spaces?  And did you really want to keep them?

 

If you want to suppress all of the invalid value messages you can just include the ?? in the INPUT statement without  also adding an informat specification.

 

Ahsan
Calcite | Level 5

When I use import wizard in sas eg it imported successfully but when I use infile statement it's physical file does not exist.

Reeza
Super User
Are you running EG on a server or locally?
Can you show the full log?
Ahsan
Calcite | Level 5

right now I am running locally and it still giving me error

ChrisHemedinger
Community Manager

Check the steps I've outlined here for adapting Import Data task code to your own production process.

 

And if your SAS server is remote, you might not have access to that H: drive -- at least, not by the same path reference.  EG's task copies the file to the server for you.  In your program, you either need to reference it differently or copy the text file as a separate step (see above blog post).

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Ahsan
Calcite | Level 5

I attached the txt file which I need to import using infile statement.

Reeza
Super User

It sounds like the file isn't the issue, access is the file, so the file isn't required. You do need to post the full log though.

Ahsan
Calcite | Level 5

I have attached the log.

Reeza
Super User

Did you try the copy path technique I mentioned? I think I said, ALT but it's really the SHIFT key instead.

https://technet.microsoft.com/en-us/library/ff678296.aspx

 

 

There's nothing I see in your code or log that indicates a problem and the file imports fine when I specify my path - albeit empty. Can you import other files in that location?

 

 

ChrisHemedinger
Community Manager

I suspect that EG is local, SAS is remote, and the file is on a locally mapped H drive.  The SAS session can't see that H drive.  If @Ahsan shares the code that the Import Data task generates, we might be able to confirm.

 

The Import Data task handles all of this by copying the local file to the remote SAS, and running the INFILE code from there.  If you want to adapt to your own independent program, then you have to follow the steps I've shared.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Reeza
Super User
That was my first thought, but when you get that error on the server, it usually has the server path and the H: part appended...unless the server also has an H drive I suppose?
Ahsan
Calcite | Level 5
how do we find a server path

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 21 replies
  • 3853 views
  • 3 likes
  • 6 in conversation