BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
CKSASEG
Fluorite | Level 6

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. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
CKSASEG
Fluorite | Level 6

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. 

View solution in original post

11 REPLIES 11
Quentin
Super User

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".

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
CKSASEG
Fluorite | Level 6

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.

 

 

Tom
Super User Tom
Super User

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?

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
SASKiwi
PROC Star

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.

CKSASEG
Fluorite | Level 6

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

 

SASKiwi
PROC Star

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.

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

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

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
CKSASEG
Fluorite | Level 6

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. 

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 901 views
  • 2 likes
  • 5 in conversation