DATA Step, Macro, Functions and more

ERROR: Physical file does not exist ( macro)

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

ERROR: Physical file does not exist ( macro)

[ Edited ]

Hi everyone,

 

I create a variable to store the file directory in it in order to modify the path easier in the futur but when i run the sas code I get this error "ERROR: Physical file does not exist." It works perfectly when i refer the path in the Infile statement.

 

I begin my code with :

 

%let path=H:\database\SAS\Txt_file\Database.txt;

then I import my txt file.

DATA MyDB;
             LENGTH
              ...
             FORMAT
              
              ...
             INFORMAT
               
              ...

            INFILE '&path'
                LRECL=584                             
ENCODING="WLATIN1" DLM=';' MISSOVER DSD firstobs=2; INPUT ... RUN;

 thank u in advance

 


Accepted Solutions
Solution
‎05-08-2017 06:57 AM
Super User
Super User
Posts: 7,407

Re: ERROR: Physical file does not exist ( macro)

Hi,

 

Why not just put it in a filename statement rather than juming through macro loops?:

filename dbfile 'h:\database\sas\txt_file\database.txt';

data mydb;
  length ...;
  format ...;
  informat ...;
  infile dbfile lrecl encoding="wlatin1" dlm=";" missover dsd firstobs=2;
  input ...;
run;

Also, considering coding in lower case, it makes code easier to read.

View solution in original post


All Replies
PROC Star
Posts: 172

Re: ERROR: Physical file does not exist ( macro)

Macro variable references do not resolve withing single quotes when called within a string literal.

Try

 

INFILE "&path"

Super User
Posts: 6,946

Re: ERROR: Physical file does not exist ( macro)

Macro variables are not resolved when enclosed by single quotes. Use double quotes in your infile statement.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎05-08-2017 06:57 AM
Super User
Super User
Posts: 7,407

Re: ERROR: Physical file does not exist ( macro)

Hi,

 

Why not just put it in a filename statement rather than juming through macro loops?:

filename dbfile 'h:\database\sas\txt_file\database.txt';

data mydb;
  length ...;
  format ...;
  informat ...;
  infile dbfile lrecl encoding="wlatin1" dlm=";" missover dsd firstobs=2;
  input ...;
run;

Also, considering coding in lower case, it makes code easier to read.

Contributor
Posts: 30

Re: ERROR: Physical file does not exist ( macro)

Because i didn't know the statement. Now I know :-D.

 

Thanks and sorry for upper case.

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 151 views
  • 2 likes
  • 4 in conversation