BookmarkSubscribeRSS Feed
invalid
Fluorite | Level 6

In EG i can per program choose either Local (windows machine with SAS EG) or SASapp (unix server with SAS running) to run the sas code.

 

I can use File Copy task to copy a file between the two. But then I need to "hardcode" the same path in TWO programs (one running on SASApp and one running on local). 

 

If the project is shared between users i must make sure all users have access to that folder to transfer a file SASapp <-> local. To get around this i want it to be dynamic. Ideally i would like to copy a dataset between SASapp WORK and Local WORK, (ie %sysfunc(pathname(work,L)) evaluated on respective machine). But then SASApp need to know the path to WORK on the Local machine.

 

Can i set a macro variable on SASApp and then transfer that value to the local session somehow? 

7 REPLIES 7
andreas_lds
Jade | Level 19
A macro-variable is bound to the session, a session running on a server is, most likely, not able to access local directories. So this won't work.
ChrisHemedinger
Community Manager

If you are copying data sets, look at the Upload SAS Data Sets and Download SAS Data Sets tasks.  These can copy SAS data set files from a remote SAS library to a local PC folder, or vice versa.

 

If these are just general files, I can't think of a clean way of doing what you want (copy macro values from local session to remote).  I can think of one very messy way though.

 

  • On Local SAS, run a SAS program that writes out current macro var values of interest to a local file (maybe even as a program, with %LET statements).
  • Use Copy Files task to transfer that file to your remote SAS session (SASApp).
  • On SASApp, run a program to %include the file you just copied.  Now you have these macro variables in your session.
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Quentin
Super User
I like Chris's idea, but I think I would transfer them with a SAS data set. You've got dictionary.macros, which holds all of the macro variables. I would think you could use PROC SQL to create a dataset from that, then push that dataset to the other SAS session, and then read the data set in a DATA step and use CALL SYMPUTX to re-generate the macro variables. One thing to keep in mind is that a macro variable with length >200 will have multiple records in dictionary.macros.

Here's a similar example of saving and restoring macro vars (which wouldn't actually handle long values, but could be adapted for your need): https://support.sas.com/kb/46/300.html

If you do it a lot, you can imagine writing macros %SaveMacroVars(out=/*output dataset name*/,mvars=/*list of macro vars to save*/) and %RestoreMacroVars(data=/*name of dataset previously created by %SaveMacroVars*/).
The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
ChrisHemedinger
Community Manager

I think @invalid was looking to grab just the one value (path to WORK).  But if I follow @Quentin down the path of over-engineering, then you could just use the Download Data Set task to "download" SASHELP.VMACRO to a sas7bdat, then use Upload SAS Data Set to copy to any library on your remote server.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
invalid
Fluorite | Level 6

Thanks all for the input.

 

If the code fails i don't want large file to be orphaned in the users personal folder. That is why i want to transfer it to work directly.

 

It seems the best solution is:

  1. On local write macrovars with path to Local work to file
  2. Transfer file to SASapp (make sure it's to somewhere where all users have access, ie a personal folder)
  3. Read in file with macrovar on SASapp
  4. Remove file on SASapp to clean up their personal folder
  5. Transfer large data file from SASapp to Local PC work

 

Reeza
Super User

Have you tried SYSRPUT or SYSLPUT?

SYSLPUT looks appropriate in this case:

https://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p13mg8ttnegfzxn15lz4aky4d3p5.htm&docse...

 

You can choose which session to pass the macro variable to, if you have multiple open using the REMOTE session ID and REMOTE option.

 


@invalid wrote:

In EG i can per program choose either Local (windows machine with SAS EG) or SASapp (unix server with SAS running) to run the sas code.

 

I can use File Copy task to copy a file between the two. But then I need to "hardcode" the same path in TWO programs (one running on SASApp and one running on local). 

 

If the project is shared between users i must make sure all users have access to that folder to transfer a file SASapp <-> local. To get around this i want it to be dynamic. Ideally i would like to copy a dataset between SASapp WORK and Local WORK, (ie %sysfunc(pathname(work,L)) evaluated on respective machine). But then SASApp need to know the path to WORK on the Local machine.

 

Can i set a macro variable on SASApp and then transfer that value to the local session somehow? 


 

ChrisHemedinger
Community Manager

SYSRPUT and SYSLPUT apply to SAS/CONNECT -- when you have two SAS sessions talking directly to each other.  That's SAS <--> SAS.

 

But with your typical EG setup, you don't have SAS/CONNECT in the middle.  It's EG connecting to your local SAS, and EG connecting to your remote SAS. EG uses SAS Integration Technologies for this work.  SAS Integration Technologies supports [any client]<-->SAS, where [any client] might be EG, SAS Add-In for MS Office, SAS DI Studio, etc.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1822 views
  • 6 likes
  • 5 in conversation