<?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: Multiple call symput in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369772#M88322</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro RandBetween(min, max);
(&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))
%mend;

%let nb_col=10;

data SAMPLE;
  set CUST_T;
  array COL[4747] COL1-COL4747; /* # columns = # customers */
  do I=1 to &amp;amp;nb_col.;
    R1=sum(R1,COL[%RandBetween(1,4747)]);
  end;
  drop COL1-COL4747 I N _NAME_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Jun 2017 03:56:37 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2017-06-23T03:56:37Z</dc:date>
    <item>
      <title>Multiple call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369729#M88305</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a large amount of customer data that is a value for each half hour period of the day.&amp;nbsp; I have the data table set up with Date; Time; and then each column is a new customer.&amp;nbsp; In case it helps what I'm doing is looking at a combination of the&amp;nbsp;customers eg 2 at time, 5, 10, 100 etc to work out at what level the diversity of the single customer is lost - ie as the group size increases my time of max demand will stablise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have come up with a way to sample the customers&amp;nbsp;for a particular level (eg this code sums the values of 10 random customers for each time and date period) but I'm sure there must be a shorter way to code this for say when I want to do a level of 100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically I'm looking for a shorter way&amp;nbsp;to create the sequence of random numbers as variables to eliminate the length of the first data step and then also a shorter way to write the R1= in the second datastep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* SAS macro that duplicates teh Excel RANDBETWEEN function*/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; RandBetween(min, max);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;min + floor((&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;max-&amp;amp;min)*rand(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"uniform"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Randomly select the columns for the calculation */&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; random;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand1"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand2"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand3"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand4"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand5"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand6"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand7"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand8"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"rand10"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,%&lt;STRONG&gt;&lt;I&gt;RandBetween&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Sums the 10 random columns*/&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; Sample;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Cust_T;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Col[&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4747&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;] col1-col4747; &lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/* # columns = # customers */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;R1=Sum(Col(&amp;amp;Rand1)+Col(&amp;amp;Rand2)+Col(&amp;amp;Rand3)+Col(&amp;amp;Rand4)+Col(&amp;amp;Rand5)&lt;/P&gt;&lt;P&gt;+Col(&amp;amp;Rand6)+Col(&amp;amp;Rand7)+Col(&amp;amp;Rand8)+Col(&amp;amp;Rand9)+Col(&amp;amp;Rand10));&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DROP&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; col1-col4747 n _Name_;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 22:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369729#M88305</guid>
      <dc:creator>jo1</dc:creator>
      <dc:date>2017-06-22T22:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369761#M88317</link>
      <description>&lt;P&gt;I feel like it would save you a lot of time to just transpose the data. Then you can use PROC SURVEYSELECT and no macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALL RANPERK may be another option, without knowing fully, it's hard to say. If you can change the order of the variables without consequence this is a good option. Remember that it doesn't have to be permanent &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A third option would be to create another array with 10 elements and create random numbers there, only once when _n_=1. Then use those with your loop, no need for macro variables here at all. Untested sample below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let window=10;
data want;
set have;

array myRand(*) _temporary_ rand1-rand&amp;amp;window;
array other(*) other1-other4564;

if _n_ = 1 then do i=1 to dim(myRand);
    myRand(i) = rand(******);
end;

total = 0;

do i=1 to dim(myRand);
total = sum(total, other(myRand(i)));
end;

run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2017 02:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369761#M88317</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-23T02:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369772#M88322</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro RandBetween(min, max);
(&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))
%mend;

%let nb_col=10;

data SAMPLE;
  set CUST_T;
  array COL[4747] COL1-COL4747; /* # columns = # customers */
  do I=1 to &amp;amp;nb_col.;
    R1=sum(R1,COL[%RandBetween(1,4747)]);
  end;
  drop COL1-COL4747 I N _NAME_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2017 03:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-call-symput/m-p/369772#M88322</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-06-23T03:56:37Z</dc:date>
    </item>
  </channel>
</rss>

