Hi,
I would like to use the same LIBNAME or macro variables across all programs within a SAS EG project. In the past, I only needed to run the Libname or %let= one time, but now I need to run these statements in every program.
Can someone tell me what I need to change in the SAS settings?
Thanks for your help in advance.
I found the cause.
The setting "Code will run on server:" was set to different servers in different programs, so the Libname/Macro Variable/Proc Format etc... can't be reused across programs.
The setting is under Properties for Program>General
Thanks everyone for your time.
You should only need to run a libname or %LET statement once per session. So if you open EG, connect to the SAS instance, and then open two programs, you're saying if you run %let foo=1; in one and %put foo; in the other, the macro variable won't be resolved? That would be odd. I don't think there is an option to say "start a new session every time I submit code".
Hi, Quentin,
Thank you for your reply.
Yes, that is what's happening in my SAS EG. I now need to repeat Libname/macro variable/proc format ... in every program.
Do you run all of the steps in your work flow as one job? Or are you opening the project and selecting a random step and trying to run it first before running any of the other steps? Do you see the difference?
Doesn't EG have an AUTOEXEC type functionality for a project? A place to put code that runs as soon as you connect to the SAS server?
Just as a sanity check, do you have the same problem with work datasets? That is, if you create a work dataset in one program, then open another program and try to read the dataset, does it exist? That would suggest you somehow have different SAS sessions for each program. I guess you could also check that by seeing if %put %sysfunc(pathname(work)) returns the same work directory is being used for both programs.
When did this change in behaviour happen and do you recall any EG or SAS changes around the same time? Something must have happened to cause the change.
Thanks everyone for taking a moment to reply.
Just to answer the questions in the replies.
- I don't run the programs in a specific order, not autoexec
- The temporary datasets work fine across programs.
- The issue appears to happen after I switched SAS server as instructed by system Admin
I suggest you talk to your system admin in that case about the change in behaviour. I'm guessing that there could be a port or configuration setting issue on your new SAS server that is closing SAS sessions prematurely.
Hello CkSasEG!
Sorry for asking again, I do not have a clear picture yet:
So it is sure that you have run the %let statement without any errors or warnings in the log?
Does the variable show up in the macro manager?
if not please try the same (for a quick fix) using the %global statement.
%global foo;
%let foo=bar;
Cheers
Fja
I'm completely lost. If work datasets can be seen by both programs, that means there is one SAS session that is being maintained.
Have you confirmed that librefs and macro variables persist across multiple submissions of the same program? (i.e. highlight code, submit, highlight another block, submit)?
All I can think is that there is some code being submitted which is clearing librefs and deleting global macro variables. It's possible with EG to specify code that is run before every submission. So if someone accidentally set up submission pre-code that would do 'cleanup', that would cause this problem across submissions.
If you run a libname statement in program A, then try to use the libref in program B and get the libref not assigned error, then if you go back to program A and try to use the libref again (without running the libname statement again), does it work? I'm hoping it would not, which would be evidence that something is happening when you submit code in B that is clearing your librefs. Also could do same test with a global macro variable.
But this is a mystery. If your admin can't help, you might want to submit to tech support.
I found the cause.
The setting "Code will run on server:" was set to different servers in different programs, so the Libname/Macro Variable/Proc Format etc... can't be reused across programs.
The setting is under Properties for Program>General
Thanks everyone for your time.
Glad you got it sorted.
If that's the case, then I would have expected that the earlier check I suggested, to see if a single work dataset could be accessed from both programs, would have revealed that it could not be accessed from both. Because each server is running its own SAS session, with its own WORK library.
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 25. Read more here about why you should contribute and what is in it for you!
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.