<?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: Running the same code for different data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402820#M278875</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122878"&gt;@Khaladdin&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just want to ask a quick question. I have 500 datasets and I want to run the same code for all datasets. The name of my datasets are TV1, TV2, .... TV500. I think I need to use MACRO statements here. So, firstly I write the code for just one dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;hints at a better answer, one that doesn't use macros. Put all the data into a single data set, and then use BY group processing to perform the analysis. Simple, efficient, requires less programming knowledge, it's a win-win-win.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 15:52:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2017-10-10T15:52:46Z</dc:date>
    <item>
      <title>Running the same code for different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402815#M278872</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just want to ask a quick question. I have 500 datasets and I want to run the same code for all datasets. The name of my datasets are TV1, TV2, .... TV500. I think I need to use MACRO statements here. So, firstly I write the code for just one dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;data KHA. TV1A;
&amp;nbsp; &amp;nbsp; &amp;nbsp;set KHA. TV1;
&amp;nbsp; &amp;nbsp; &amp;nbsp;by datetime;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if first.datetime then V = 0;
&amp;nbsp; &amp;nbsp; &amp;nbsp;V+volume;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if last.datetime then output;
&amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I test the following code (I got it from your communities, as well), however I cannot get results:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO repeat(dslist=);
%DO i=1 %TO %SYSFUNC(COUNTW(&amp;amp;dslist));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET ds = %SCAN(&amp;amp;dslist, &amp;amp;i);
&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA &amp;amp;ds;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET &amp;amp;ds;
&amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp; by datetime;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if first.datetime then V = 0;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp;V+volume;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if last.datetime then output;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RUN;
%END;
%MEND repeat;
%repeat(dslist= TV1, TV2, .... TV500);&lt;/CODE&gt;&lt;/PRE&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;P&gt;&lt;SPAN&gt;Could you please help me about that? Could you please give me any other ways to run the same code for multiple assets?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402815#M278872</guid>
      <dc:creator>Khaladdin</dc:creator>
      <dc:date>2017-10-10T15:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running the same code for different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402816#M278873</link>
      <description>&lt;P&gt;Try passing the list in without comma's separating the data set names.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402816#M278873</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T15:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Running the same code for different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402817#M278874</link>
      <description>&lt;P&gt;Also, this is why you shouldn't split your data sets in the first place. Your code doesn't show any mistakes from a quick first glance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest running it with a list of two data sets and then posting the output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure you have the macro debuggging options set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen mlogic;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402817#M278874</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T15:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Running the same code for different data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402820#M278875</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122878"&gt;@Khaladdin&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just want to ask a quick question. I have 500 datasets and I want to run the same code for all datasets. The name of my datasets are TV1, TV2, .... TV500. I think I need to use MACRO statements here. So, firstly I write the code for just one dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;hints at a better answer, one that doesn't use macros. Put all the data into a single data set, and then use BY group processing to perform the analysis. Simple, efficient, requires less programming knowledge, it's a win-win-win.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-the-same-code-for-different-data-sets/m-p/402820#M278875</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-10T15:52:46Z</dc:date>
    </item>
  </channel>
</rss>

