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

 

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

 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:

 

http://support.sas.com/documentation/cdl/en/connref/67933/HTML/default/viewer.htm#n1bc4zi0lp02ivn1ox...

 

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

 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:

 

http://support.sas.com/documentation/cdl/en/connref/67933/HTML/default/viewer.htm#n1bc4zi0lp02ivn1ox...

 

Shayan2012
Quartz | Level 8

Thanks a lot. %SYSLPUT seems like the exact thing I was looking for!

 

 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

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.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1889 views
  • 1 like
  • 2 in conversation