BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Junyong
Pyrite | Level 9

%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?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

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?

Junyong
Pyrite | Level 9

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

ChrisNZ
Tourmaline | Level 20

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

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!

How to Concatenate Values

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.

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
  • 3 replies
  • 1069 views
  • 0 likes
  • 2 in conversation