If you change to using libname XLSX do you have the same problem?
I think the Excel file might be locked after the libname statement runs. But then you can use libname libref clear; to explicitly clear the libref, and release the lock.
I suppose it's possible that PROC IMPORT is creating a libref behind the scenes, and somehow the statement to clear the libref is failin on occasion.. Just a guess. I don't use PROC IMPORT much.
@Michael_W - I am a developer on EG and just noticed your reply today. Apologies for not noticing this topic sooner.
A few thoughts:
I am very puzzled at the difference in behavior between disconnecting the workspace server in EG and exiting EG. They should have the same effect.
But if I read this thread correctly, stopping and restarting the server session doesn't cause the lock to be released. If the only reference to the xlsx file is in the sas code, then EG is not accessing the file. All access is taking place on the server.
If this last point is correct, (shutdown releases but disconnect and reconnect doesn't), then I recommend:
That log will help me determine if there is some extra step that is causing the exit to behave differently than the disconnect. I have reviewed the code and do not see anything.
I'm sorry this is proving difficult to resolve - I understand it must be very frustrating.
Thanks,
Mark Allemang
I don't use EG but it does have the same functionality as SAS/Studio where you can re-start the SAS session (or switch to a different SAS server for that matter) without having stop EG.
In SAS/Studio it is located in the menu that is just to the left of the ? icon.
@Michael_W wrote:
Responding to both of your recent posts ...
Yes, the disconnect option released the file but is not a suitable workaround. Sure I could update the code to fix the problem (which I did), but it doesn't explain why SAS is locking the file when an error of this type is encountered. SAS should be able recover from an error that it has encountered and release the file, IMO.
Agree, a graceful exit is always to be preferred.
Just wondering, your initial thread did not mention getting an error during PROC IMPORT. In your further explorations, did you find this locking problem only happens when your receive an ERROR from your WHERE statement? If so, it might be helpful to provide that information to tech support, to see if they will agree to open the issue as a bug. It seems much better defined if the problem is reproducible. It's certainly plausible that the error is causing SAS to exit the PROC without releasing a lock, and that would feel like a bug to me.
@Michael_W wrote:
Hi,
I included the log which had the error message from the very start. To repeat, the error is not the problem, it's SAS unwillingness to release the file after the error is encountered. In your further explorations, did you find this locking problem only happens when your receive an ERROR from your WHERE statement? Well no. The WHERE clause is failing cause the error to occur and thereby locking up the file. I can't reach tech support other than to call them as their portal is unavailable (maybe blocked by us who knows).
I was referring to you original message from the start of this thread (from 2023); it did not have an error message. It said that the PROC IMPORT ran successfully.
But now it sounds like when the WHERE clause causes an ERROR, SAS is not releasing the file lock (which sounds like a bug).
I was not clear how that bug relates to your initial report of this problem, from 2023. It's interesting that in your initial report, you say it ran successfully, but the output dataset had 0 obs. So maybe you missed an error message in the intial report, or maybe there is a related bug where SAS doesn't release the lock when you PROC IMPORT an Excel file with 0 obs.
Can you also post the log you get when you fix the PROC IMPORT code to prevent the invalid expression issue?
PROC IMPORT
DATAFILE="G:\Risk Adjustment\Edge Server Processing\Change Control ables\Revenue and Enrollment\2024\Enrollment Segs to Exclude - Test.xlsx"
OUT=CCT_Segs2ExclA (WHERE=(cats(PPI) EQ '1') RENAME=(IssuerEnrolleeID=SubID_))
DBMS=XLSX REPLACE;
SHEET="Excluded Segments_2024"
;
RUN;
Does that code generate the data you want?
Does it end up with the XLSX file being locked?
You should report that to SAS also, because that seems at odds with your earlier statement that it is only locking the file when the PROC IMPORT step reported an ERROR.
@Michael_W
Based on what you have learned, I recommend opening the track again with tech support with this new information. I suspect there is a problem in PROC IMPORT that results in the file access not being closed in the scenario you are hitting. Tech support should be able to route that then.
Key points for the track are that the problem happens in both EG and SAS Studio, and ending the workspace session causes the lock to release.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.