Hi:
A FILENAME statement is designed to point to data files that are NOT SAS data sets. A file that you point to with a FILENAME statement is generally a non-proprietary, ASCII text file or "flat file" that you want to read with SAS INPUT and INFILE statements in order to turn the file from it's "flat" form into SAS dataset form.
A LIBNAME statement is designed to give you a naming method for SAS datasets that is somewhat platform independent. So on UNIX and WINDOWS, I might have the "SOMEDATA.SAS7BDAT" SAS dataset file in these locations:
UNIX: /usr/bin/sasczz/mydata/somedata.sas7bdat
WIN: c:\temp\somedata.sas7bdat
And so if I had the following LIBNAME statements on each system:
UNIX: libname perm '/usr/bin/sasczz/mydata/somedata.sas7bdat';
WIN: libname perm 'c:\temp\somedata.sas7bdat';
Then this program would work on EITHER platform -- as long as the correct LIBNAME statement was issued before I submitted the code:
[pre]
data new;
set perm.somedata;
run;
proc freq data=perm.somedata;
tables charvar;
run;
[/pre]
However if you wanted to write a program that referenced the absolute operating filename and path, you can do so. Let's look at a WINDOWS example:
[pre]
data new;
set 'c:\temp\somedata.sas7bdat';
run;
proc print data='c:\temp\somedata.sas7bdat';
run;
proc freq data='c:\temp\somedata.sas7bdat';
tables age;
run;
[/pre]
However, the downside of this approach is that you will now have a program that can ONLY run on a WINDOWS platform and ONLY run when the data is exactly in this location. What if FRED, who also has a copy of SOMEDATA.SAS7BDAT, wants to borrow a copy of your program -- but he put his data in this location:
c:\data\fred\test\somedata.sas7bdat
That means that he will not be able to use your program until ALL the path references are changed. Or, what if you are writing and testing a program on your local drive, but plan to deploy that program on a server where the SAS dataset is stored in a different location??? Again, you would have to change all the physical file references in the entire program, instead of just changing a single LIBNAME statement.
When you have an existing SAS dataset, you would never read it with an INFILE/INPUT statement. When you have a operating system file with the extension of SAS7BDAT, that file is a proprietary format SAS dataset and should be referenced in your program with a SET statement or a DATA= option, as shown in my code snippet. Is there a reason you do not want to use a LIBNAME statement????
cynthia