<?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: find all possible sum of variables that amount to a value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974747#M377974</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;Sorry, I had oversimplfiied the code, which I have now corrected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The corrected line is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set VARS {IDS} init VARS_ALL;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Sep 2025 14:49:57 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2025-09-10T14:49:57Z</dc:date>
    <item>
      <title>find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974259#M377854</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input id target var1 var2 var3 var4 var5 var6;&lt;BR /&gt;cards;&lt;BR /&gt;1 10000 -2000 10000 3000 7000 12000 30&lt;BR /&gt;2 7000 5000 1500 500 6500 750 .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each id I want to find all possible combinations of variables (var1-var6) whose sum among them is equal to target. Missing values do not have to enter in any combination.&lt;/P&gt;
&lt;P&gt;The result I am looking for is something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input id var $ value sol1 sol2 sol3 ;&lt;BR /&gt;cards;&lt;BR /&gt;1 var1 -2000 0 0 1&lt;BR /&gt;1 var2 10000 1 0 0&lt;BR /&gt;1 var3 3000 0 1 0&lt;BR /&gt;1 var4 7000 0 1 0&lt;BR /&gt;1 var5 12000 0 0 1&lt;BR /&gt;1 var6 30 0 0 0&lt;BR /&gt;2 var1 5000 1 0 .&lt;BR /&gt;2 var2 1500 1 0 .&lt;BR /&gt;2 var3 500 1 1 .&lt;BR /&gt;2 var4 6500 0 1 .&lt;BR /&gt;2 var5 750 0 0 .&lt;BR /&gt;2 var6 . 0 0 .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;each variable sol (sol1-sol3) is equal to 1 if the corresponding var has to be considered in the sum.&lt;/P&gt;
&lt;P&gt;any suggestion is very welcome.&lt;/P&gt;
&lt;P&gt;Moreover it is very appreciated any advice on alternative structures of have and/or want data&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 15:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974259#M377854</guid>
      <dc:creator>ciro</dc:creator>
      <dc:date>2025-09-05T15:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974272#M377861</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114"&gt;@ciro&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The suggestion below is built around the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1myrepjl958iin1ikhv6515cgp4.htm" target="_blank" rel="noopener"&gt;GRAYCODE function&lt;/A&gt;, which generates all subsets of {VAR1, ..., VAR6}. It creates a WANT dataset in a different structure: one observation per solution with binary variables W1, ..., W6 indicating which of the VAR&lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt; are included in the sum.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
if 0 then set have;
array _[*] var:;
call symputx('n',dim(_));
stop;
run;

data want(keep=id target var: w:);
set have;
array v[*] var:;
array w[&amp;amp;n];
k=-1;
do j=1 to 2**&amp;amp;n;
  r=graycode(k, of w[*]);
  e=1; /* eligibility flag to exclude missing values */
  do i=1 to &amp;amp;n while(e);
    if w[i]=1 &amp;amp; v[i]=. then e=0;
  end;
  if e then do;
    s=0;
    do i=1 to &amp;amp;n;
      if w[i]=1 then s+v[i];
    end;
    if s=target then output;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Edit:&lt;/U&gt; If your real data contain &lt;EM&gt;non-integer&lt;/EM&gt;&amp;nbsp; VAR&lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt; values, make sure to round the sum S appropriately when comparing it to TARGET in order to avoid surprises (due to numeric precision issues) as shown in the log below:&lt;/P&gt;
&lt;PRE&gt;800 data _null_;&lt;BR /&gt;801 retain var1-var3 target (33.3 33.4 33.3 100);&lt;BR /&gt;802 s=sum(of var:);&lt;BR /&gt;803 if s ne target then put 'Surprised?';&lt;BR /&gt;804 if &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;round(s, 1e-9)&lt;/STRONG&gt;&lt;/FONT&gt;=target then put 'OK!';&lt;BR /&gt;805 run;&lt;BR /&gt;&lt;BR /&gt;Surprised?&lt;BR /&gt;OK!&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Sep 2025 17:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974272#M377861</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-09-05T17:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974317#M377881</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; has already given you the GRAYCODE() solution.&lt;/P&gt;
&lt;P&gt;But I would suggest to use a more sophisticated solution SAS/OR and calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code is for your first record 's solution . and I found 3 solutions:&lt;/P&gt;
&lt;P&gt;And I believe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp; could give you better code , the condition is you have SAS/OR software.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input v $ Column1;
cards;
var1  -2000 
var2 10000 
var3 3000 
var4 7000 
var5 12000 
var6 30
;

proc optmodel;
set idx ;
str var{idx};
num x{idx};
var v{idx} binary;

read data have into  idx=[_n_] var=v x=Column1 ;
con con1:sum{i in idx} v[i]*x[i]=10000 ;
solve with clp/findallsolns;
create data want from [solution index]={s in 1.._NSOL_,i in idx} vname=var[i] value=x[i] flag=v[i].sol[s];
quit;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1757150105766.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109670i65D29CC5F34E7553/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1757150105766.png" alt="Ksharp_0-1757150105766.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Sep 2025 09:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974317#M377881</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-06T09:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974328#M377882</link>
      <description>&lt;P&gt;That GRAYCODE function is interesting.&lt;/P&gt;
&lt;P&gt;Why not use it to generate a score dataset that you could use with PROC SCORE?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=6;
data have;
  input id target var1-var&amp;amp;n ;
cards;
1 10000 -2000 10000 3000 7000 12000 30
2  7000 5000 1500 500 6500 750 .
;

data score;
  _type_='SCORE';
  length _name_ $32 ;
  array var[&amp;amp;n] ;
  nterms=-1;
  do j=1 to 2**&amp;amp;n;
    r=graycode(nterms,of var[*]);
    _name_=cats('X',of var[*]);
    if nterms then output;
  end;
  keep _type_ _name_ var: ;
run;

proc score data=have score=score out=wide;
  var var:;
  id id target;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you could use PROC TRANSPOSE to get to something similar to the requested output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=wide name=inputs out=solutions(where=(col1=target));
  by id target;
  var x: ;
run;

data solutions;
  sol+1;
  set solutions;
  by id target ;
  output;
  if last.target then sol=0;
  drop col1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1757173246225.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109673iFDFEF6340798D4CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1757173246225.png" alt="Tom_0-1757173246225.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Sep 2025 16:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974328#M377882</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-06T16:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974346#M377890</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That GRAYCODE function is interesting.&lt;/P&gt;
&lt;P&gt;Why not use it to generate a score dataset that you could use with PROC SCORE?&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's a great idea which makes the code more efficient by avoiding unnecessary calls of the GRAYCODE function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114"&gt;@ciro&lt;/a&gt;: To exclude the trivial solution W1=W2=...=W6=0 in case of TARGET=0 with my DATA step approach (as Tom's code does already), insert a conditional CONTINUE statement as shown below:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#999999"&gt;...
do j=1 to 2**&amp;amp;n;
  r=graycode(k, of w[*]);
&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;  if r=0 then continue;&lt;/FONT&gt;&lt;/STRONG&gt;
  ...&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Sep 2025 16:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974346#M377890</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-09-07T16:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974468#M377910</link>
      <description>&lt;P&gt;Extending the CLP approach by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;, here's a way to do it with a groupBy parameter in the runOptmodel action in SAS Optimization:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numVars = 6;

data mycas.have;
   input id target var1-var&amp;amp;numVars;
   cards;
1 10000 -2000 10000 3000 7000 12000 30
2 7000 5000 1500 500 6500 750 .
;

proc cas;
   source pgm;
   num target;
   set VARS init 1..&amp;amp;numVars;
   num a {VARS};
   read data have into target {j in VARS} &amp;lt;a[j]=col('var'||j)&amp;gt;;
   VARS = {j in VARS: a[j] ne .};

   var Select {VARS} binary;
   con SumToTarget:
      sum {j in VARS} a[j] * Select[j] = target;

   solve with clp / findallsolns;

   create data want(drop=j) from [solution j]={s in 1.._NSOL_, j in VARS} var=('var'||j) value=a[j] sol=Select[j].sol[s];
   endsource;
   action optimization.runOptmodel / code=pgm groupBy='id';
quit;

proc print data=mycas.want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RobPratt_0-1757349492678.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109733iC4BB33A2A4EF6C4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RobPratt_0-1757349492678.png" alt="RobPratt_0-1757349492678.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 16:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974468#M377910</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-08T16:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974586#M377942</link>
      <description>&lt;P&gt;Thank you very much everyone for all this ideas and code. Once again, this list proves to be an invaluable tool for support and for learning new things about SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;as I don't have Sas Viya can you suggest the code only with SAS/OR?&lt;/P&gt;
&lt;P&gt;Thank you very much in advance&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 09:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974586#M377942</guid>
      <dc:creator>ciro</dc:creator>
      <dc:date>2025-09-09T09:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974669#M377964</link>
      <description>&lt;P&gt;As requested, here's an alternative approach that uses a COFOR loop in PROC OPTMODEL and works in both SAS/OR (SAS 9) and SAS Optimization (SAS Viya):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel printlevel=0;
   set IDS;
   num target {IDS};
   set VARS_ALL = 1..&amp;amp;numVars;
   set VARS {IDS} init VARS_ALL;
   num a {id in IDS, VARS[id]};
   read data have into IDS=[id] target {j in VARS_ALL} &amp;lt;a[id,j]=col('var'||j)&amp;gt;;
   for {id in IDS} VARS[id] = {j in VARS_ALL: a[id,j] ne .};

   num id_this;
   var Select {VARS[id_this]} binary;
   con SumToTarget:
      sum {j in VARS[id_this]} a[id_this,j] * Select[j] = target[id_this];

   set SOLS {IDS};
   num SelectSol {id in IDS, SOLS[id], VARS[id]};
   cofor {id in IDS} do;
      put id=;
      id_this = id;
      solve with clp / findallsolns;
      SOLS[id_this] = 1.._NSOL_;
      for {s in SOLS[id_this], j in VARS[id_this]} SelectSol[id_this,s,j] = Select[j].sol[s];
   end;

   create data want(drop=j) from [id solution j]={id in IDS, s in SOLS[id], j in VARS[id]} var=('var'||j) value=a[id,j] sol=SelectSol;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2025 14:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974669#M377964</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-10T14:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974719#M377972</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I am running your code, and get these error info .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let numVars = 6;
 70         
 71         data have;
 72            input id target var1-var&amp;amp;numVars;
 73            cards;
 
 NOTE: 数据集 WORK.HAVE 有 2 个观测和 8 个变量。
 NOTE: “DATA 语句”所用时间（总处理时间）:
       实际时间          0.00 秒
       用户 CPU 时间     0.00 秒
       系统 CPU 时间     0.00 秒
       内存              672.21k
       OS 内存           19876.00k
       时间戳           2025-09-10 上午07:23:33
       Step Count                        24  Switch Count  2
       页错误数                       0
       页回收数                     139
       页交换数                        0
       主动上下文切换数        10
       被动上下文切换数      0
       块输入操作数            0
       块输出操作数           264
       
 
 76         ;
 77         
 78         proc optmodel printlevel=0;
 79            set IDS;
 80            num target {IDS};
 81            set VARS_ALL = 1..&amp;amp;numVars;
 82            set VARS {IDS};
 83            num a {id in IDS, VARS[id]};
 84            read data have into IDS=[id] target {j in VARS_ALL} &amp;lt;a[id,j]=col('var'||j)&amp;gt;;
 ERROR: 数组元素“VARS[1]”在第 83 行第 22 列没有值。
 NOTE: 从数据集 WORK.HAVE. 读取了 1 个观测
 85            for {id in IDS} VARS[id] = {j in VARS_ALL: a[id,j] ne .};
 ERROR: 数组元素“VARS[1]”在第 83 行第 22 列没有值。
 86         
 87            num id_this;
 88            var Select {VARS[id_this]} binary;
 89            con SumToTarget:
 90               sum {j in VARS[id_this]} a[id_this,j] * Select[j] = target[id_this];
 91         
 92            set SOLS {IDS};
 93            num SelectSol {id in IDS, SOLS[id], VARS[id]};
 94            cofor {id in IDS} do;
 95               put id=;
 96               id_this = id;
 97               solve with clp / findallsolns;
 98               SOLS[id_this] = 1.._NSOL_;
 99               for {s in SOLS[id_this], j in VARS[id_this]} SelectSol[id_this,s,j] = Select[j].sol[s];
 100           end;
 NOTE: The COFOR statement is executing in single-machine mode.
 id=1
 NOTE: 问题生成将使用 2 个线程。
 NOTE: 先前的错误可能会导致问题无法正确解决。
 ERROR: 数组元素“VARS[1]”在第 88 行第 16 列没有值。
 NOTE: 由于先前的错误，无法创建问题实例。
 101        
 102           create data want(drop=j) from [id solution j]={id in IDS, s in SOLS[id], j in VARS[id]} var=('var'||j) value=a[id,j]
 102      ! sol=SelectSol;
 ERROR: 数组元素“SOLS[1]”在第 102 行第 67 列没有值。
 103        quit;
 NOTE: 由于出错，SAS 系统停止处理该步。
 NOTE: “PROCEDURE OPTMODEL”所用时间（总处理时间）:
       实际时间          0.01 秒
       用户 CPU 时间     0.01 秒
       系统 CPU 时间     0.00 秒
       内存              1077.60k
       OS 内存           20648.00k
       时间戳           2025-09-10 上午07:23:33
       Step Count                        25  Switch Count  6
       页错误数                       4
       页回收数                     501
       页交换数                        0
       主动上下文切换数        48
       被动上下文切换数      0
       块输入操作数            928
       块输出操作数           168
       
 104        
 105        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 115        &lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Sep 2025 08:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974719#M377972</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-10T08:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: find all possible sum of variables that amount to a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974747#M377974</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;Sorry, I had oversimplfiied the code, which I have now corrected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The corrected line is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set VARS {IDS} init VARS_ALL;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Sep 2025 14:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-all-possible-sum-of-variables-that-amount-to-a-value/m-p/974747#M377974</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-09-10T14:49:57Z</dc:date>
    </item>
  </channel>
</rss>

