<?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 set a macro variable  that can be read from different sas programs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537732#M147932</link>
    <description>&lt;P&gt;I have a 3 macro files that I call all 3 macro a main sas program. In one of those macro file, I need a variable that I create called "Value1". How can I access that macro variable from another 2 macro file&amp;nbsp; and/or the main file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried %global value1; but it can only be called within 1 macro file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2019 15:53:16 GMT</pubDate>
    <dc:creator>Shonesum</dc:creator>
    <dc:date>2019-02-22T15:53:16Z</dc:date>
    <item>
      <title>How to set a macro variable  that can be read from different sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537732#M147932</link>
      <description>&lt;P&gt;I have a 3 macro files that I call all 3 macro a main sas program. In one of those macro file, I need a variable that I create called "Value1". How can I access that macro variable from another 2 macro file&amp;nbsp; and/or the main file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried %global value1; but it can only be called within 1 macro file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 15:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537732#M147932</guid>
      <dc:creator>Shonesum</dc:creator>
      <dc:date>2019-02-22T15:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable  that can be read from different sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537733#M147933</link>
      <description>&lt;P&gt;We're guessing.&amp;nbsp; We can't see your macros, we can't see the program that calls the macros, we can't see your data.&amp;nbsp; So here's a guess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can depend on where this statement goes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global value1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Place it in the program that calls the macros, before any macros get called.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 15:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537733#M147933</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-22T15:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable  that can be read from different sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537734#M147934</link>
      <description>&lt;P&gt;Lets say we have 3&amp;nbsp; files with 1 macro in each:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sas1.sas&amp;nbsp;&lt;/P&gt;&lt;P&gt;%global value1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%macro sas1()&lt;/P&gt;&lt;P&gt;%let value1 ="apple";&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sas2.sas&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%macro sas2()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sas3.sas&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%macro sas2()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;macromain.sas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%sas1;&lt;/P&gt;&lt;P&gt;%sas2;&lt;/P&gt;&lt;P&gt;%sas3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I access that value1 macro from sas1 file to sas2.sas and sas3.sas? How can I access that value 1 from sas1 in macromain.sas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537734#M147934</guid>
      <dc:creator>Shonesum</dc:creator>
      <dc:date>2019-02-22T16:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable  that can be read from different sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537737#M147937</link>
      <description>&lt;P&gt;Just reference it.&amp;nbsp; So in your main program you could do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sas1;
%put Value of Value1 is &amp;amp;value1;
%sas2;
%sas3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Similarly inside of %SAS2() and %SAS3().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sas2;

%put Value of Value1 is &amp;amp;value1;

%mend sas2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537737#M147937</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-22T16:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable  that can be read from different sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537739#M147938</link>
      <description>&lt;P&gt;You can.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test that yourself, where you have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%sas1;&lt;/P&gt;
&lt;P&gt;%sas2;&lt;/P&gt;
&lt;P&gt;%sas3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a diagnostic statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%sas1;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;valuie1;&lt;/P&gt;
&lt;P&gt;%sas2;&lt;/P&gt;
&lt;P&gt;%sas3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely, you are assigning &amp;amp;VALUE1 the incorrect value.&amp;nbsp; In your statements, you have assigned a 7-character value (quotes included) not a 5-character value.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537739#M147938</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-22T16:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable  that can be read from different sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537748#M147941</link>
      <description>&lt;P&gt;If you're submitting your programs via batch this may not work because each program could be running in a separate session.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you're using %INCLUDE, this is how I build my 'control' programs. This allows the macro variable myVar to be available to all programs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let myVar = TEST;

%let path_master = /folders/myfolders/projectABC

*Import data;
%include "&amp;amp;path_master/programs/P001 Import Data.sas";


*Clean data;
%include "&amp;amp;path_master/programs/P002 Clean Data.sas";


*Generate reports
%include "&amp;amp;path_master/programs/P003 Report Data.sas";&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248486"&gt;@Shonesum&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Lets say we have 3&amp;nbsp; files with 1 macro in each:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sas1.sas&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global value1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;%macro sas1()&lt;/P&gt;
&lt;P&gt;%let value1 ="apple";&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sas2.sas&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;%macro sas2()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sas3.sas&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;%macro sas2()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;macromain.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%sas1;&lt;/P&gt;
&lt;P&gt;%sas2;&lt;/P&gt;
&lt;P&gt;%sas3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I access that value1 macro from sas1 file to sas2.sas and sas3.sas? How can I access that value 1 from sas1 in macromain.sas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-can-be-read-from-different-sas/m-p/537748#M147941</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T16:34:26Z</dc:date>
    </item>
  </channel>
</rss>

