<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to define a macro variable for SAS connect? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302126#M64033</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%let bgnyr = 2002;&lt;BR /&gt;%let endyr = 2004;&lt;BR /&gt;&lt;BR /&gt;%signonWRDS;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table crspfund as select * from want&lt;BR /&gt; where &amp;amp;bgnyr &amp;lt;= year(caldt) &amp;lt;= &amp;amp;endyr;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%signonWRDS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let bgnyr = 2002;&lt;BR /&gt;%let endyr = 2004;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table crspfund as select * from want&lt;BR /&gt;where &amp;amp;bgnyr &amp;lt;= year(caldt) &amp;lt;= &amp;amp;endyr;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2016 18:21:15 GMT</pubDate>
    <dc:creator>Shayan2012</dc:creator>
    <dc:date>2016-10-03T18:21:15Z</dc:date>
    <item>
      <title>How to define a macro variable for SAS connect?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302126#M64033</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%let bgnyr = 2002;&lt;BR /&gt;%let endyr = 2004;&lt;BR /&gt;&lt;BR /&gt;%signonWRDS;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table crspfund as select * from want&lt;BR /&gt; where &amp;amp;bgnyr &amp;lt;= year(caldt) &amp;lt;= &amp;amp;endyr;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%signonWRDS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let bgnyr = 2002;&lt;BR /&gt;%let endyr = 2004;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table crspfund as select * from want&lt;BR /&gt;where &amp;amp;bgnyr &amp;lt;= year(caldt) &amp;lt;= &amp;amp;endyr;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 18:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302126#M64033</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2016-10-03T18:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a macro variable for SAS connect?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302132#M64037</link>
      <description>&lt;P&gt;&amp;nbsp;My suspicion is that the&amp;nbsp;&lt;SPAN&gt;%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.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can use %SYSLPUT to define your local macro variables in the remote session once you have signed on:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/connref/67933/HTML/default/viewer.htm#n1bc4zi0lp02ivn1oxn9gc1bsaha.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/connref/67933/HTML/default/viewer.htm#n1bc4zi0lp02ivn1oxn9gc1bsaha.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 18:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302132#M64037</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-10-03T18:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a macro variable for SAS connect?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302164#M64054</link>
      <description>&lt;P&gt;Thanks a lot. %SYSLPUT&amp;nbsp;seems like the exact thing I was looking for!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 20:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-macro-variable-for-SAS-connect/m-p/302164#M64054</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2016-10-03T20:08:08Z</dc:date>
    </item>
  </channel>
</rss>

