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-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
  • 2 replies
  • 1414 views
  • 1 like
  • 2 in conversation