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
"testalias" contains 9 characters. You are limited to 8 characters for the name in the FILENAME statement.
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
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
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.
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
"testalias" contains 9 characters. You are limited to 8 characters for the name in the FILENAME statement.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.