%syslput and %sysrput assign a global macro variable as a result.
/*remote access*/
%let wrds=wrds.wharton.upenn.edu 4016;
signon wrds username=_prompt_;
/*pass local macro ONE to remote*/
%macro one(one);
%syslput one=&one;
rsubmit;
%put &one;
endrsubmit;
%mend;
/*prints 1234 remotely*/
%one(1234)
/*ONE works globally*/
rsubmit;
%sysrput one=&one;
endrsubmit;
/*prints 1234 here*/
%put &one;Can I assign a local macro variable in this case?
> I want to create a server-side local (rather than global) macro variable from a local-side local macro variable.
I understand you mean local as in in macro-local, not host-local.
You can't since %syslput sends the value to the remote host outside of a remote macro environment.
%macro have(local_var_at_local);
%syslput local_var_at_server=&local_var_at_local; /* sending a host-local macro-local variable to the remote host, no macro-local environment on that host */
rsubmit; /* connecting to the remote host macro-global environment */
%put &local_var_at_server is NOT a local macro variable at the server session.; /* nothing local here */
endrsubmit;
%mend;
%have
The only way would be to pull (rather than push/send) macro variables from the remote host from within a macro. There is no command to execute such a pull.
Your question is confusing.
%SYSLPUT is submitted in a (most likely local) session and creates/copies macro variables to the server session.
%SYSRPUT is remote-submitted to retrieve the value of a macro variable stored on the remote host and creates/updates macro variables on the calling (most likely local) session.
So they copy macro variable values from a SAS session to another.
What do you want to do?
%SYSLPUT is submitted in a (most likely local) session and creates/copies macro variables to the server session—here %SYSLPUT passes either local or global macro variables from the local session to the server session only as global macro variables.
%macro have(local_var_at_local);
%syslput local_var_at_server=&local_var_at_local;
rsubmit;
%put &local_var_at_server is a local macro variable at the server session.
endrsubmit;
%mend;
%have
rsubmit;
%put &local_var_at_server is available though was local inside have macro;
endrsubmit;I want to create a server-side local (rather than global) macro variable from a local-side local macro variable.
> I want to create a server-side local (rather than global) macro variable from a local-side local macro variable.
I understand you mean local as in in macro-local, not host-local.
You can't since %syslput sends the value to the remote host outside of a remote macro environment.
%macro have(local_var_at_local);
%syslput local_var_at_server=&local_var_at_local; /* sending a host-local macro-local variable to the remote host, no macro-local environment on that host */
rsubmit; /* connecting to the remote host macro-global environment */
%put &local_var_at_server is NOT a local macro variable at the server session.; /* nothing local here */
endrsubmit;
%mend;
%have
The only way would be to pull (rather than push/send) macro variables from the remote host from within a macro. There is no command to execute such a pull.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.