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:
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:
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:
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. This is exactly what I wanted to do. Actually I am using enterprize guide where in user could select File throught the prompt and I can easily run sas codes without using the libname and stuff ...
It is possible to create a libname pointing to your local computer. To do this you need your computer name in the network. Right click on My Computer -> Properties -> Computer Name and write the contents of the entry Full Computer Name. Then use it
in libname like this:
libname mylib "\\\C$\abb";
Pay attention that C: -> C$. This approach is valid for Windows XP.