<?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: Randomly selected contracts sum of value equal to a desired value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592950#M170083</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/175837"&gt;@Myurathan&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try following step-by-step:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test;
input name $ value $;
datalines;
hjk 500
lku 985
ldu 689
lll 951
lkh 147
qwe 653
lkt 566
sads 658
;
run;

data test1;
set test(keep=value) curobs=co;
curobs=co;
call streaminit(123);
r = rand("uniform");
run;
proc sort data = test1;
by r;
run;

data test1(keep=curobs);
set test1;
s+value;
output;
if s &amp;gt; 3000 then 
  do;
    call symputx("NOBS",_N_,"G");
    stop;
  end;
run;

data saple;
  array S[&amp;amp;NOBS.] _temporary_;
  do until(eof);  
    set test1 end = eof;
    _I_ + 1;
    S[_I_] = curobs;
  end;
  drop _I_ curobs;
  call sortn(of S[*]);
  do _I_ = lbound(S) to hbound(S);
    point = S[_I_]; 
    set test point = point;
    output;
  end;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2019 09:00:51 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2019-10-01T09:00:51Z</dc:date>
    <item>
      <title>Randomly selected contracts sum of value equal to a desired value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592941#M170080</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will have to select random entries from a large data set. The condition is sum of their values should be close to a value I choose in the beginning. It is easy to explain with the following test data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test;
input name $ value $;
datalines;
hjk 500
lku 985
ldu 689
lll 951
lkh 147
qwe 653
lkt 566
sads 658
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to randomly select names and their total sum of values should be close to 3000. therefore, I can choose the following names hjk, ldu, qwe, lkt, and, sads. Total summation of their values equal to 3066.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do thi sSAS with a very large data set?&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 08:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592941#M170080</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2019-10-01T08:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected contracts sum of value equal to a desired value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592950#M170083</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/175837"&gt;@Myurathan&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try following step-by-step:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test;
input name $ value $;
datalines;
hjk 500
lku 985
ldu 689
lll 951
lkh 147
qwe 653
lkt 566
sads 658
;
run;

data test1;
set test(keep=value) curobs=co;
curobs=co;
call streaminit(123);
r = rand("uniform");
run;
proc sort data = test1;
by r;
run;

data test1(keep=curobs);
set test1;
s+value;
output;
if s &amp;gt; 3000 then 
  do;
    call symputx("NOBS",_N_,"G");
    stop;
  end;
run;

data saple;
  array S[&amp;amp;NOBS.] _temporary_;
  do until(eof);  
    set test1 end = eof;
    _I_ + 1;
    S[_I_] = curobs;
  end;
  drop _I_ curobs;
  call sortn(of S[*]);
  do _I_ = lbound(S) to hbound(S);
    point = S[_I_]; 
    set test point = point;
    output;
  end;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 09:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592950#M170083</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-10-01T09:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected contracts sum of value equal to a desired value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592953#M170086</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&lt;BR /&gt;Thank you so so much. It worked like a charm.</description>
      <pubDate>Tue, 01 Oct 2019 09:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-contracts-sum-of-value-equal-to-a-desired/m-p/592953#M170086</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2019-10-01T09:12:33Z</dc:date>
    </item>
  </channel>
</rss>

