Hi,
I am writing a program which includes connecting to a web service (WRDS databases) to download some data. As I have noticed, if I define the macro variables before connecting to the WRDS, it will not recognize the varibale. This is what I have right now:
%let bgnyr = 2002;
%let endyr = 2004;
%signonWRDS;
proc sql;
create table crspfund as select * from want
where &bgnyr <= year(caldt) <= &endyr;
quit;
So this does not work, because the macro variables are not recognized. I know that If I define the macro varibales after connection, it works. like this:
%signonWRDS;
%let bgnyr = 2002;
%let endyr = 2004;
proc sql;
create table crspfund as select * from want
where &bgnyr <= year(caldt) <= &endyr;
quit;
But then, If I disconnect and continue on my local machine, I need to redefine the macro variables. I know that it is not a big deal, but I was curious to know if there is a way to define the macros in a general way that it will apply to both situations at once?
Thanks a lot
My suspicion is that the %signonWRDS macro hides a remote submit to a remote SAS server (RSUBMIT). Defining your macro variable before the remote submit defines them for your local SAS session only. When you define them after the remote submit then it defines them on the remote server session where the SQL query runs.
You can use %SYSLPUT to define your local macro variables in the remote session once you have signed on:
My suspicion is that the %signonWRDS macro hides a remote submit to a remote SAS server (RSUBMIT). Defining your macro variable before the remote submit defines them for your local SAS session only. When you define them after the remote submit then it defines them on the remote server session where the SQL query runs.
You can use %SYSLPUT to define your local macro variables in the remote session once you have signed on:
Thanks a lot. %SYSLPUT seems like the exact thing I was looking for!
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.