DATA Step, Macro, Functions and more

infile statement in sas

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

infile statement in sas

Hi when i use the below mentioned sas code to access the data, it throws the error-physical file does not exist. I am using sas studio. and have added the text data into my sas folder. 

  I have attached the file showing the error.

Do is need to add anything else.

data price;
infile="/folders/myfolders/data_infile.txt";
input brand $ model $ price;
run;


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 10,571

Re: infile statement in sas


@subhra07 wrote:

Have tried with the full path and got error too.

this is the code

data price;
infile="F:\SASUniversityEdition\myfolders\data_infile.txt" dlm = '09'x;
input brand $ model $ price;
run;


This can never work in UE, as the virtual machine only "sees" the UNIX file system.

Have you tried '/folders/myfolder/data_infile.txt'? (if set up correctly, the shared folder has no trailing s in the VM)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Contributor
Posts: 28

Re: infile statement in sas

[ Edited ]

If you right click on the files and choose properties, you can see the file location

Occasional Contributor
Posts: 7

Re: infile statement in sas

Have tried with the full path and got error too.

this is the code

data price;
infile="F:\SASUniversityEdition\myfolders\data_infile.txt" dlm = '09'x;
input brand $ model $ price;
run;

Solution
2 weeks ago
Super User
Posts: 10,571

Re: infile statement in sas


@subhra07 wrote:

Have tried with the full path and got error too.

this is the code

data price;
infile="F:\SASUniversityEdition\myfolders\data_infile.txt" dlm = '09'x;
input brand $ model $ price;
run;


This can never work in UE, as the virtual machine only "sees" the UNIX file system.

Have you tried '/folders/myfolder/data_infile.txt'? (if set up correctly, the shared folder has no trailing s in the VM)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 7

Re: infile statement in sas

Posted in reply to KurtBremser

Yes I have tried that and it worked fine. 

One more doubt. Will it work the same way '/folders/myfolder/data_infile.txt' in SAS enterprise guide or do i have to give the full path "F:\SASUniversityEdition\myfolders\data_infile.txt" dlm = '09'x

 

Thanks 

Super User
Posts: 10,571

Re: infile statement in sas


@subhra07 wrote:

Yes I have tried that and it worked fine. 

One more doubt. Will it work the same way '/folders/myfolder/data_infile.txt' in SAS enterprise guide or do i have to give the full path "F:\SASUniversityEdition\myfolders\data_infile.txt" dlm = '09'x

 

Thanks 


You can't use Enterprise Guide with University Edition.

Apart from that, it always depends on where the SAS process itself runs, and how files are brought into the respective server environment.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 7

Re: infile statement in sas

Posted in reply to KurtBremser

I am not using EG with university edition.

the EG is working with office server. 

I would like to know if we could import text files using the infile statement. And if so, what would be the code like?

Thanks.

Super User
Super User
Posts: 8,279

Re: infile statement in sas

[ Edited ]

@subhra07 wrote:

I am not using EG with university edition.

the EG is working with office server. 

I would like to know if we could import text files using the infile statement. And if so, what would be the code like?

Thanks.


The INFILE statement works the same no matter where SAS is running.

 

But you do need to understand where your files are on the machine where SAS itself is running.  If it is not machine where your browser or SAS Enterprise Guide is running then the path you use in SAS will most likely be different than what you would use on your PC.  Also remember that SAS University Edition is using a virtual machine to run SAS.

Super User
Posts: 10,571

Re: infile statement in sas


@subhra07 wrote:

I am not using EG with university edition.

the EG is working with office server. 

I would like to know if we could import text files using the infile statement. And if so, what would be the code like?

Thanks.


What @Tom said. You need to somehow make the file "visible" to the SAS process, either by copying it to the server, or using a shared resource that is accessible by both your desktop and the server, or by using a resource shared from the server that is mounted on your desktop. Either way, the path will be different from what you use on your PC.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 7

Re: infile statement in sas

Have got the solution. There should not be equal sign after infile statement

Super User
Posts: 10,571

Re: infile statement in sas


@subhra07 wrote:

Have got the solution. There should not be equal sign after infile statement


Ouch. At least one of us should have caught that immediately. Going for additional coffee.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 94 views
  • 2 likes
  • 4 in conversation