<?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: How can I use two variables do loop to create 25 files? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427907#M68491</link>
    <description>&lt;P&gt;I'm sorry to bother all of you, and meanwhile thank you for your support.&lt;BR /&gt;I just arbitrarily chose two statements to test if (j,k) can work properly. At the same, my intention for this is that I can easily find the report corresponding to different (j,k).&lt;BR /&gt;Astounding’s reply was exactly what we wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2018 03:07:45 GMT</pubDate>
    <dc:creator>vickyCh</dc:creator>
    <dc:date>2018-01-16T03:07:45Z</dc:date>
    <item>
      <title>How can I use two variables do loop to create 25 files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427614#M68461</link>
      <description>&lt;P&gt;How can I create 25 my_class&amp;amp;j&amp;amp;k files, if one of the file (my_class36) from (j,k)=(3,6) is as follows?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET j=3;&lt;BR /&gt;%LET k=6;&lt;BR /&gt;data my_class&amp;amp;j&amp;amp;k;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;height&amp;amp;j=height*&amp;amp;j;&lt;BR /&gt;weight&amp;amp;k=weight*&amp;amp;k;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There 25 combinations of j and k, if j=1,3,6,9, &amp;amp; 12 and k=1,3,6,9,&amp;amp; 12.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 08:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427614#M68461</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-15T08:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use two variables do loop to create 25 files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427615#M68462</link>
      <description>&lt;P&gt;Why do you want those datasets? Sounds like a very, very strange requirement. Problem can be solved by using two nested loops in data-null-step or macro.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 08:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427615#M68462</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-01-15T08:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use two variables do loop to create 25 files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427619#M68463</link>
      <description>&lt;P&gt;That really is not a good approach.&amp;nbsp; If you go that way then every proc or datastep you write from that point on will have to be duplicated for each dataset.&amp;nbsp; Unless its for an export of data or report, its never a good idea to split data up - SAS is geared towards using what is called by groups (which are simpler to program with and faster).&amp;nbsp; So say for your example, a simpler way would be:&lt;/P&gt;
&lt;PRE&gt;data want;
  set sashelp.class;
  do j=3;
    do k=6;
      output;
    end;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;In this way you have one dataset to work with, with a fixed set of variables (ie. they are all height weight so no need to mess around with arrays), and you can by group on the j and k variables e.g:&lt;/P&gt;
&lt;PRE&gt;proc print data=want;
  by j k;
  title "Group #byval1 section #byval2";
run;&lt;/PRE&gt;
&lt;P&gt;So much simpler than trying to loop each time.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 09:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427619#M68463</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-15T09:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use two variables do loop to create 25 files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427692#M68464</link>
      <description>&lt;P&gt;The previous posters might be right.&amp;nbsp; This might not be a great idea.&amp;nbsp; But it is difficult to evaluate unless we know your true intent.&amp;nbsp; (Certainly you aren't working with sashelp.class in real life.)&amp;nbsp; Just in case you remain steadfast in pursuing your original question, here is a macro to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro all25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %local j_list k_list j k&amp;nbsp; j_index k_index;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %let j_list = 1 3 6 9 12;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %let k_list = 1 3 6 9 12;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %do j_index=1 %to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let j = %scan(&amp;amp;j_list, &amp;amp;j_index);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %do k_index=1 %to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%let k = %scan(&amp;amp;k_list, &amp;amp;k_index);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data my_class&amp;amp;j&amp;amp;k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set sashelp.class;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; height&amp;amp;j = height * &amp;amp;j;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; weight&amp;amp;k = weight * &amp;amp;k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend all25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%all25&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program has to jump through some minor hoops, because macro language imposes restrictions on what forms of the %DO statement are available.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 14:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427692#M68464</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-15T14:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use two variables do loop to create 25 files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427836#M68490</link>
      <description>&lt;P&gt;the solutions provided are probably sound, but I am curious as to why you want to do this?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 21:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427836#M68490</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-15T21:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use two variables do loop to create 25 files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427907#M68491</link>
      <description>&lt;P&gt;I'm sorry to bother all of you, and meanwhile thank you for your support.&lt;BR /&gt;I just arbitrarily chose two statements to test if (j,k) can work properly. At the same, my intention for this is that I can easily find the report corresponding to different (j,k).&lt;BR /&gt;Astounding’s reply was exactly what we wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 03:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-use-two-variables-do-loop-to-create-25-files/m-p/427907#M68491</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-16T03:07:45Z</dc:date>
    </item>
  </channel>
</rss>

