<?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 Re: global macro variables with inter-program scope? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93243#M19660</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If they are run in the same SAS session global macro variables will be available in any program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use this approach to set a date stamp string in a specific format in my AUTOEXEC.SAS file so it doesn't have to be created in each program.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Apr 2012 17:01:09 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2012-04-24T17:01:09Z</dc:date>
    <item>
      <title>global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93242#M19659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;I'm running a series of SAS programs which calculate bootstrap confidence intervals. In order to cut the run time, I'm running a series of programs in a timed sequence, with 5 bootstrap programs running simultaneously:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;data_prep -&amp;gt; bootstrap1 &amp;amp; bootstrap2 &amp;amp; bootstrap3 &amp;amp; bootstrap4 &amp;amp; bootstrap5 -&amp;gt; compile_results&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;It would be awesome if I could declare a macro variable only once, say in the initial data_prep program, and then pass on the value of that macro variable to the subsequent programs rather than having to "hard code" the macro variable value in each bootstrap program. The fewer parameters I have to tweak the fewer errors I'll make. &lt;/SPAN&gt;&lt;SPAN style="font-size: 14pt;"&gt;Is it possible to create global macro variables with inter-program scope?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Any thoughts/suggestions are welcome!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Robert&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2012 16:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93242#M19659</guid>
      <dc:creator>RobertWF</dc:creator>
      <dc:date>2012-04-24T16:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93243#M19660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If they are run in the same SAS session global macro variables will be available in any program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use this approach to set a date stamp string in a specific format in my AUTOEXEC.SAS file so it doesn't have to be created in each program.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2012 17:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93243#M19660</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-04-24T17:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93244#M19661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, thank you - will global macro variables work when running my programs in batch mode from Unix?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2012 17:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93244#M19661</guid>
      <dc:creator>RobertWF</dc:creator>
      <dc:date>2012-04-24T17:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93245#M19662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are looking for system options SYSPARM= .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SYSPARM Details&lt;/P&gt;&lt;P&gt;The value of the SYSPARM automatic macro variable is the same as the value of the&lt;/P&gt;&lt;P&gt;SYSPARM= system option, which is equivalent to the return value of the SAS language&lt;/P&gt;&lt;P&gt;function SYSPARM. The default value is null. Because you can use the SYSPARM=&lt;/P&gt;&lt;P&gt;system option at SAS invocation, you can set the value of the SYSPARM automatic&lt;/P&gt;&lt;P&gt;macro variable before your SAS session begins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2012 05:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93245#M19662</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-25T05:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93246#M19663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp, the -SYSPARM option worked well as a command line option when running individual SAS programs in batch mode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;sasb bootprogram1 -sysparm 100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where the value of "100" is passed on to the sample size variable in my bootstrap program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let numsamp=&amp;amp;sysparm;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When running multiple SAS programs in a shell script, I noticed the SYSPARM option has to be added to each program in the script text file rather than on the actual command line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So executing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;shell.sh -sysparm 2&lt;/P&gt;&lt;P&gt;where shell.sh contains&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sasb bootprogram1 &amp;amp; sasb bootprogram2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;does not execute properly, but&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;shell.sh&lt;/P&gt;&lt;P&gt;where shell.sh contains&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sasb bootprogram1 -sysparm 2 &amp;amp; sasb bootprogram2 -sysparm 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;does work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2012 17:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93246#M19663</guid>
      <dc:creator>RobertWF</dc:creator>
      <dc:date>2012-04-25T17:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93247#M19664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I expect you don't need to run multiple jobs to speed up your bootstrap.&amp;nbsp; I think you just need to fix it to work better/faster.&amp;nbsp; Start a new thread we will have lots of fun fixing it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2012 21:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93247#M19664</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-04-25T21:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93248#M19665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Store your parameters in a file or dataset.&amp;nbsp; Then each job can read them from there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use a CSV text file then you can do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile 'parms' dsd ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length name $32 value $200;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input name value;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; call symputx(name,value);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use a dataset then you can do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set 'parms.sas7bdat';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; call symputx(name,value);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2012 23:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93248#M19665</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-25T23:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93249#M19666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. system options SYSPARM= is a SAS system option ,not UNIX system option.&lt;/P&gt;&lt;P&gt;But you can set its value in AUTOEXEC.SAS . so everytime start a sas session ,sas will take care of this option.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2012 04:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93249#M19666</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-26T04:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: global macro variables with inter-program scope?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93250#M19667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use SYSGET to retrieve the value of a system/environment variable.&amp;nbsp;&amp;nbsp;&amp;nbsp; There is a macro and a data step version of the function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A name="a000503585"&gt;&lt;/A&gt;%SYSGET&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;A name="a000503586"&gt;&lt;/A&gt;returns the character string that is the value of the environment variable passed as the argument. Both UNIX and SAS environment variables can be translated using the %SYSGET function. A warning message is written if the global variable does not exist. Here is the form of the %SYSGET function: &lt;/P&gt;&lt;P&gt;&lt;A name="a002545571"&gt;&lt;/A&gt;&lt;/P&gt;&lt;TABLE cellpadding="4" cellspacing="2"&gt;&lt;TBODY&gt;&lt;TR valign="top"&gt;&lt;TD&gt;&lt;SPAN class="strong"&gt;%SYSGET&lt;/SPAN&gt;(&lt;SPAN class="emph"&gt;environment-variable&lt;/SPAN&gt;); &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;A name="a000503587"&gt;&lt;/A&gt;For example, the following code writes the value of the HOME environment variable to the SAS log: &lt;/P&gt;&lt;PRE class="jive-pre"&gt;&lt;A name="a000357631"&gt;&lt;/A&gt;%let var1=%sysget(HOME);&amp;nbsp; %put &amp;amp;var1;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2012 12:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/global-macro-variables-with-inter-program-scope/m-p/93250#M19667</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-04-26T12:35:31Z</dc:date>
    </item>
  </channel>
</rss>

