G'day.
I have placed a filename near the end of a SAS program and am getting the following error message:
ERROR: At least one file associated with fileref IMPORT is still in use.
ERROR: Error in the FILENAME statement.
This is the filename code. When I run the file SAS program.sas by itself, I don't get an error statement. Howeber, when I run the program the code below sits in, I get the error statement.
filename importv 'C:\SAS Programs\SAS program.sas';
%include importv;
Any help you can give will e much appreciated. Thank you.
What is the name of the the program file that contains the shown statements? IF that name is
'C:\SAS Programs\SAS program.sas';
then it is open in the editor and is used by the editor.
If the program that contains those two lines has a different name then possibly another program is attempting to us SAS Program.sas.
Or possibly one or more of the statements inside the file when %included is in use. You may have to examine the contents of SAS Program.sas to see what external files may be used. Example: if that program is supposed to read another file that is open in the editor you could get that message.
Please, in the future if you are going to show an ERROR do not separate it from the rest of the code. Include from the log the entire data step, procedure or other statements that are related to causing the error.
Are you trying to do some thing with the file that is active in the editor? Then the Editor has the file "in use".
Can you help me understand: When you ask, am I trying to do something with the file that is active in the editor, do as you asking if I am trying to use a file that was created in the sas program that the filename statement is at the end of? Or are you asking if I'm trying to do something with the SAS program file that is in the filename statement?
Based on your question, I selected the 'Break' button to cancel anything that had been running. Then I reran the program that the filename statement is at the end of, and no error came up.
Then, I closed SAS, reopened it and the program ran with no errors including the filename import statement at the end. I am trying to figure out if I'm doing something wrong and not do it again in the future. Thank you.
What is the name of the the program file that contains the shown statements? IF that name is
'C:\SAS Programs\SAS program.sas';
then it is open in the editor and is used by the editor.
If the program that contains those two lines has a different name then possibly another program is attempting to us SAS Program.sas.
Or possibly one or more of the statements inside the file when %included is in use. You may have to examine the contents of SAS Program.sas to see what external files may be used. Example: if that program is supposed to read another file that is open in the editor you could get that message.
Please, in the future if you are going to show an ERROR do not separate it from the rest of the code. Include from the log the entire data step, procedure or other statements that are related to causing the error.
To see more detail in the SAS log use the SOURCE2 option. Either set it with an OPTIONS statement or include it in the %INCLUDE statement.
%include importv / source2;
Thank you both🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.