<?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 passing a variable to a macro parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331624#M74555</link>
    <description>&lt;P&gt;I haven't worked with macros in awhile, so please bear with me. &amp;nbsp;I am wanting to simulate some data using specific seed numbers.I have 20 pairs of values for seed1 and seed2. The following is what I have sketched out for one pair of seed1 and seed2 values, but I don't know how to create a loop that runs through the set of 20 values (do while?). appreciate some pointers. thanks jm&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro xone(seed1= seed2=);&lt;/P&gt;
&lt;P&gt;data samples;&lt;BR /&gt;do samp = 1 to 100;&lt;BR /&gt;do t = 1 to 100;&lt;BR /&gt; u = rannor(&amp;amp;seed1)*5;&lt;BR /&gt; x = 100 + 3*rannor(&amp;amp;seed2);&lt;BR /&gt; y = 10 + 0.5*x + u;&lt;BR /&gt; output;&lt;BR /&gt; end ;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%xone(seed1=1234, seed2=4567);&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2017 18:36:19 GMT</pubDate>
    <dc:creator>doylejm</dc:creator>
    <dc:date>2017-02-10T18:36:19Z</dc:date>
    <item>
      <title>passing a variable to a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331624#M74555</link>
      <description>&lt;P&gt;I haven't worked with macros in awhile, so please bear with me. &amp;nbsp;I am wanting to simulate some data using specific seed numbers.I have 20 pairs of values for seed1 and seed2. The following is what I have sketched out for one pair of seed1 and seed2 values, but I don't know how to create a loop that runs through the set of 20 values (do while?). appreciate some pointers. thanks jm&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro xone(seed1= seed2=);&lt;/P&gt;
&lt;P&gt;data samples;&lt;BR /&gt;do samp = 1 to 100;&lt;BR /&gt;do t = 1 to 100;&lt;BR /&gt; u = rannor(&amp;amp;seed1)*5;&lt;BR /&gt; x = 100 + 3*rannor(&amp;amp;seed2);&lt;BR /&gt; y = 10 + 0.5*x + u;&lt;BR /&gt; output;&lt;BR /&gt; end ;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%xone(seed1=1234, seed2=4567);&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 18:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331624#M74555</guid>
      <dc:creator>doylejm</dc:creator>
      <dc:date>2017-02-10T18:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: passing a variable to a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331628#M74557</link>
      <description>&lt;P&gt;Use call execute:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
input seed1 seed2;
call execute('%xone(seed1='!!put(seed1,best.)!!',seed2='!!put(seed2,best.)!!');');
cards;
1234 4567
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2017 18:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331628#M74557</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-10T18:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: passing a variable to a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331641#M74562</link>
      <description>&lt;P&gt;Kurt - thank you very much. It worked great. &amp;nbsp;Each pair of seed1, seed2 has a student's name associated with it. &amp;nbsp;I want to add in the student's name and have the program print out the seed1, seed2 and name as well as the proc means&amp;nbsp;for the data that are generated for each student. In the code below, I used title &amp;amp;seed1 &amp;amp;seed2 before the proc mean and it worked (altho I am sure there is probably a better way), but when I add in name it doesn't print the name. I made a number of attempts, but am quite unfamiliar with call execute . &amp;nbsp;any ideas? thanks again!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options ls=78 formdlim='*' nodate nonumber nolabel;&lt;BR /&gt;ods listing;&lt;/P&gt;
&lt;P&gt;%macro xone(seed1,seed2,name);&lt;/P&gt;
&lt;P&gt;data samples;&lt;BR /&gt;do samp = 1 to 10;&lt;BR /&gt;do t = 1 to 100;&lt;BR /&gt; u = rannor(&amp;amp;seed1)*5;&lt;BR /&gt; x = 100 + 3*rannor(&amp;amp;seed2);&lt;BR /&gt; y = 10 + 0.5*x + u;&lt;BR /&gt; output;&lt;BR /&gt; end ;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;title &amp;amp;seed1 &amp;amp;seed2 &amp;amp;name;&lt;BR /&gt;proc means;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;input seed1 seed2 name $;&lt;BR /&gt;call execute('%xone(seed1='!!put(seed1,best.)!!',seed2='!!put(seed2,best.)!!',name);');&lt;BR /&gt;cards;&lt;BR /&gt;1234 4567 Doyle&lt;BR /&gt;1117 7111 Boyce&lt;/P&gt;
&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 19:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331641#M74562</guid>
      <dc:creator>doylejm</dc:creator>
      <dc:date>2017-02-10T19:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: passing a variable to a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331645#M74563</link>
      <description>&lt;P&gt;I think you need a slight change:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute('%xone(seed1='!!put(seed1,best.)!!',seed2='!!put(seed2,best.)!!','!!name!!');');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2017 19:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331645#M74563</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-10T19:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: passing a variable to a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331652#M74567</link>
      <description>&lt;P&gt;Yes, this worked great. thanks again&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt;name='&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;!!&lt;/SPAN&gt;name&lt;SPAN class="token operator"&gt;!!&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 19:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/passing-a-variable-to-a-macro-parameter/m-p/331652#M74567</guid>
      <dc:creator>doylejm</dc:creator>
      <dc:date>2017-02-10T19:48:16Z</dc:date>
    </item>
  </channel>
</rss>

