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

Hi,

This is my first post.  I have searched for this error on these boards, but the solutions I am finding do not seem to specifically solve my issue.  I am using Ron Cody's book "Learning SAS by Example."  I created a virtual box on my machine and I access SAS University Edition through the localhost:10080 address.  In the material, Ron has supplied two files, mydata.csv and mydata.txt.  They are the same information inside, one is just comma delimited and the other is space delimited.  I am trying to use the filename statement to alias a file.  I am getting an error in response.

 

This statement works just fine to read the file:

 

data Demographics;


infile "/folders/myfolders/sasuser.v94/mydata.csv" dsd;


input Gender $ Age Height Weight;


run;

This statement, however, does not:

 

filename testalias "/folders/myfolders/sasuser.v94/mydata.csv";

data Demographics; 

infile testalias dsd;

input Gender $ Age Height Weight;

run; 

When I run the second program, I get the following error:

ERROR: Physical file does not exist, /opt/sasinside/SASConfig/Lev1/SASApp/TESTALIAS

 

I am assuming there is something about the filename statement that I am not understanding, but I haven't been able to find a good answer online.

 

Let me know,

 

Adam

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

"testalias" contains 9 characters.  You are limited to 8 characters for the name in the FILENAME statement.

View solution in original post

5 REPLIES 5
Reeza
Super User

Post your log from both sets of code please. 

I would expect to see an error on your filename statement. 


@ahosey01 wrote:

Hi,

This is my first post.  I have searched for this error on these boards, but the solutions I am finding do not seem to specifically solve my issue.  I am using Ron Cody's book "Learning SAS by Example."  I created a virtual box on my machine and I access SAS University Edition through the localhost:10080 address.  In the material, Ron has supplied two files, mydata.csv and mydata.txt.  They are the same information inside, one is just comma delimited and the other is space delimited.  I am trying to use the filename statement to alias a file.  I am getting an error in response.

 

This statement works just fine to read the file:

 

data Demographics;


infile "/folders/myfolders/sasuser.v94/mydata.csv" dsd;


input Gender $ Age Height Weight;


run;

This statement, however, does not:

 

filename testalias "/folders/myfolders/sasuser.v94/mydata.csv";

data Demographics; 

infile testalias dsd;

input Gender $ Age Height Weight;

run; 

When I run the second program, I get the following error:

ERROR: Physical file does not exist, /opt/sasinside/SASConfig/Lev1/SASApp/TESTALIAS

 

I am assuming there is something about the filename statement that I am not understanding, but I haven't been able to find a good answer online.

 

Let me know,

 

Adam


 

 

ahosey01
Calcite | Level 5

Here is the log containing the error: 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         filename testalias "/folders/myfolders/sasuser.v94/mydata.csv";
 ERROR: Invalid logical name.
 ERROR: Error in the FILENAME statement.
 74         
 75         data Demographics;
 76         
 77         infile testalias dsd;
 78         
 79         input Gender $ Age Height Weight;
 80         
 81         run;
 
 ERROR: Physical file does not exist, /opt/sasinside/SASConfig/Lev1/SASApp/TESTALIAS.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.DEMOGRAPHICS may be incomplete.  When this step was stopped there were 0 observations and 4 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds

 

Here is the log from the program that runs fine:

 

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         data Demographics;
 74         
 75         infile "/folders/myfolders/sasuser.v94/mydata.csv" dsd;
 76         
 77         input Gender $ Age Height Weight;
 78         
 79         run;
 
 NOTE: The infile "/folders/myfolders/sasuser.v94/mydata.csv" is:
       Filename=/folders/myfolders/sasuser.v94/mydata.csv,
       Owner Name=sasdemo,Group Name=sas,
       Access Permission=-rw-rw-r--,
       Last Modified=04May2018:21:29:28,
       File Size (bytes)=73
 
 NOTE: 5 records were read from the infile "/folders/myfolders/sasuser.v94/mydata.csv".
       The minimum record length was 13.
       The maximum record length was 13.
 NOTE: The data set WORK.DEMOGRAPHICS has 5 observations and 4 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 80         
Kurt_Bremser
Super User

NEVER, EVER start fixing ERRORs from the bottom up. Fix the first ERROR in the log first, then see how much this helped, and then tackle the next one (if there's one left at all).

 

In your case, fixing the logical name problem will automatically fix everything else.

 

Also note the importance of posting the whole log.

ahosey01
Calcite | Level 5

I am so new to this that I didn't even realize 'invalid logical name' was referring to the character length.  My only exposure to programming has been to write CL programs on the i Series and errors containing the word 'logical' mean something totally different - my presumption (obviously incorrecty) was that the error was based on the path through which the SAS program was accessing the file.  This makes a lot of sense, thanks everyone.

 

Adam

Astounding
PROC Star

"testalias" contains 9 characters.  You are limited to 8 characters for the name in the FILENAME statement.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2090 views
  • 0 likes
  • 4 in conversation