<?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: Create all possible combination out of dynamic length variables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320473#M9206</link>
    <description>&lt;P&gt;Well, to answer your question first, do loops need to, when a list of values is provided, be separated by commas not spaces:&lt;/P&gt;
&lt;PRE&gt;%let x = 1,2,5;
%let y = 10,15;
%let z = 5,15,25,60,80;

data GridSearch;
 do a = &amp;amp;x.;
   do b = &amp;amp;y.;
     do c = &amp;amp;z.;
       output;
     end;
   end;
 end;
run;&lt;/PRE&gt;
&lt;P&gt;Now, from my side, I would increment the indentation for each loop to make the code readable.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2016 11:18:52 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-12-21T11:18:52Z</dc:date>
    <item>
      <title>Create all possible combination out of dynamic length variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320463#M9204</link>
      <description>&lt;P&gt;I have three macro variables that contai some dynamic values - the number of values or the values themselves may change in the script flow.&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;%let x = 1 2 5;
%let y = 10 15;
%let z = 5 15 25 60 80;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create all possible combinations out of these variables and save the data - it would contain 3*2*5 = 30 rows. I looked at &lt;EM&gt;proc plan&amp;nbsp;&lt;/EM&gt;and&amp;nbsp;it doesn't seem to ba able to do this, not directly at least. Also tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data GridSearch;&lt;BR /&gt; do a = SYMGET('x');&lt;BR /&gt; do b = SYMGET('y');&lt;BR /&gt; do c = SYMGET('z');&lt;BR /&gt;  output;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;Apparently this is not the correct way to reference maro varaible as it returns the as text rather than lsit of values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 10:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320463#M9204</guid>
      <dc:creator>BogdanC</dc:creator>
      <dc:date>2016-12-21T10:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination out of dynamic length variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320473#M9206</link>
      <description>&lt;P&gt;Well, to answer your question first, do loops need to, when a list of values is provided, be separated by commas not spaces:&lt;/P&gt;
&lt;PRE&gt;%let x = 1,2,5;
%let y = 10,15;
%let z = 5,15,25,60,80;

data GridSearch;
 do a = &amp;amp;x.;
   do b = &amp;amp;y.;
     do c = &amp;amp;z.;
       output;
     end;
   end;
 end;
run;&lt;/PRE&gt;
&lt;P&gt;Now, from my side, I would increment the indentation for each loop to make the code readable.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 11:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320473#M9206</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-12-21T11:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination out of dynamic length variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320475#M9207</link>
      <description>&lt;PRE&gt;

%let x = 1 2 5;
%let y = 10 15;
%let z = 5 15 25 60 80;

data want;
 do x=%sysfunc(translate(&amp;amp;x,%str(,),%str( )));
  do y=%sysfunc(translate(&amp;amp;y,%str(,),%str( )));
   do z=%sysfunc(translate(&amp;amp;z,%str(,),%str( )));
    output;
   end;
  end;
 end;
run;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Dec 2016 11:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Create-all-possible-combination-out-of-dynamic-length-variables/m-p/320475#M9207</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-21T11:24:58Z</dc:date>
    </item>
  </channel>
</rss>

