<?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: SAS macro - looping through list and creating new dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497653#M131976</link>
    <description>&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Split_Data_into_Subsets" target="_blank"&gt;http://www.sascommunity.org/wiki/Split_Data_into_Subsets&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 03:29:39 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-21T03:29:39Z</dc:date>
    <item>
      <title>SAS macro - looping through list and creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497648#M131972</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, I have a data-set that looks like something along the following(lets call this data-set A):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;var1&lt;/TD&gt;&lt;TD&gt;var2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i am trying to do, is loop through var2 and export different datasets based on the value of var2. So in this example, i would create four data-sets, each out corresponding to the unique amount of values in var2(var2 is numeric).&amp;nbsp; Right now, i grab the unique amount of values from a different data-set(lets call it B) and put them into a list with this code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; select var2 into :list separated by ' ' from B; quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From there I am trying to run the following code to create the data-sets.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro splitting;
%do i=1 %to %sysfunc(countw(&amp;amp;list.));
	%let block&amp;amp;i. = %scan(&amp;amp;list., &amp;amp;i.,%str());
	%put block&amp;amp;i.
		proc sql;
		    create table table&amp;amp;i. as 
		    select *
		    from A
		    where var2 contains &amp;amp;block&amp;amp;i.;
		quit;
%end;
%mend splitting; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I could, go through and do many different if-then statements, but i would rather not considering how many different data-sets I need to create.&amp;nbsp; Can someone shed some light on the situation. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 03:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497648#M131972</guid>
      <dc:creator>jrdykstr93</dc:creator>
      <dc:date>2018-09-21T03:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro - looping through list and creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497653#M131976</link>
      <description>&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Split_Data_into_Subsets" target="_blank"&gt;http://www.sascommunity.org/wiki/Split_Data_into_Subsets&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 03:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497653#M131976</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-21T03:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro - looping through list and creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497662#M131984</link>
      <description>The general consensus is to not do this, by group processing is efficient though there are a few procs that don’t support it. In those cases, it’s still usually easier to filter on the fly with a WHERE option. &lt;BR /&gt;&lt;BR /&gt;Most people still disregard this and use an approach as outlined in the posts from novinosrin.</description>
      <pubDate>Fri, 21 Sep 2018 03:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497662#M131984</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-21T03:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro - looping through list and creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497866#M132126</link>
      <description>&lt;P&gt;ok, sounds good. I guess why I am trying to do this is because I am trying to stack multiple occurrences of the same variable in the same by-group that i need to make the "ID" when i transpose, and then append the data-sets together&amp;nbsp; &amp;nbsp;I will probably post another question based on this, than rather looping through macros.&amp;nbsp; Please take a look.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 15:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497866#M132126</guid>
      <dc:creator>jrdykstr93</dc:creator>
      <dc:date>2018-09-21T15:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro - looping through list and creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497900#M132147</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Transposing-and-Stacking/m-p/497899" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Transposing-and-Stacking/m-p/497899&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Link to new questions.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 16:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-looping-through-list-and-creating-new-dataset/m-p/497900#M132147</guid>
      <dc:creator>jrdykstr93</dc:creator>
      <dc:date>2018-09-21T16:38:23Z</dc:date>
    </item>
  </channel>
</rss>

