Help using Base SAS procedures

ERROR: Physical file does not exist

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

ERROR: Physical file does not exist

Dear All,

I ran into problem when I put path into macros. SAS has no problem to read in the data without macros.

 

Below are the SAS code and log. Thanks.

 

********************************************************************;

%let pat=C:\Users\zzz\Desktop\EEE\Dryrun2018\;

%let percent= &pat.Percentile_from_2017\;

FILENAME PT "&percent.NN2_2017_SS_FREQ" ; /*Percentile*/

 

data PT;

   set PT ;

run;

 

 

 

 

938  %let pat=C:\Users\zzz\Desktop\EEE\Dryrun2018\;

939  %let percent= &pat.Percentile_from_2017\;

SYMBOLGEN:  Macro variable PAT resolves to C:\Users\zzz\Desktop\EEE\Dryrun2018\

940  FILENAME PT "&percent.NN2_2017_SS_FREQ" ; /*Percentile*/

SYMBOLGEN:  Macro variable PERCENT resolves to

            C:\Users\zzz\Desktop\EEE\Dryrun2018\Percentile_from_2017\

941

942  data PT;

943     set PT ;

944  run;

 

NOTE: There were 0 observations read from the data set WORK.PT.

NOTE: The data set WORK.PT has 0 observations and 0 variables.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 


Accepted Solutions
Solution
‎04-17-2018 10:24 AM
Super User
Posts: 13,583

Re: ERROR: Physical file does not exist

The FILENAME statement is intended to reference a non-SAS file.

SET is intended to read data from a SAS library.

When you say

set PT;

SAS is looking for a data set named PT in the default LIBRARY of work. Equivalent statement would be:

set Work.PT;

 

If the location represented by &percent is supposed to have SAS data sets (files with extensions like sas7bdat)

then you would use a LIBNAME statement to tell SAS you expect to find or place SAS data sets in that location.

Libname PT "&percent"; for example.

Then if there is data set named NN2_2017_SS_FREQ in that library use as:

 

data PT;

    set PT.NN2_2017_SS_FREQ;

run;

Note the period between the library name and the data set name.

 

OR was FILENAME PT "&percent.NN2_2017_SS_FREQ" ; intended to reference a LIBRARY? Then use LIBNAME but you still need to use the LIBNAME.datasetname syntax.

 

BTW use of

Data Pt;

   set Pt;

<other code>;

run;

Overwrites the existing Pt data set and may remove or alter data such that you no longer have what you expect.

Better, at least until you are much more familiar with SAS syntax to use:

data Pt2;

   set Pt;

to avoid that.

View solution in original post


All Replies
Solution
‎04-17-2018 10:24 AM
Super User
Posts: 13,583

Re: ERROR: Physical file does not exist

The FILENAME statement is intended to reference a non-SAS file.

SET is intended to read data from a SAS library.

When you say

set PT;

SAS is looking for a data set named PT in the default LIBRARY of work. Equivalent statement would be:

set Work.PT;

 

If the location represented by &percent is supposed to have SAS data sets (files with extensions like sas7bdat)

then you would use a LIBNAME statement to tell SAS you expect to find or place SAS data sets in that location.

Libname PT "&percent"; for example.

Then if there is data set named NN2_2017_SS_FREQ in that library use as:

 

data PT;

    set PT.NN2_2017_SS_FREQ;

run;

Note the period between the library name and the data set name.

 

OR was FILENAME PT "&percent.NN2_2017_SS_FREQ" ; intended to reference a LIBRARY? Then use LIBNAME but you still need to use the LIBNAME.datasetname syntax.

 

BTW use of

Data Pt;

   set Pt;

<other code>;

run;

Overwrites the existing Pt data set and may remove or alter data such that you no longer have what you expect.

Better, at least until you are much more familiar with SAS syntax to use:

data Pt2;

   set Pt;

to avoid that.

Super User
Posts: 23,776

Re: ERROR: Physical file does not exist


@ZhenLi wrote:

Dear All,

I ran into problem when I put path into macros. SAS has no problem to read in the data without macros.

 

 

 


Show us the code that works.

 

 

 

Occasional Contributor
Posts: 13

Re: ERROR: Physical file does not exist

I did as 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 188 views
  • 3 likes
  • 3 in conversation