<?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: Resolving loop counter inside a DATA step without using MACRO. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226864#M40857</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To mu knowledge, the SET statement is executed at compilation time, therefore you can not just change the table name on the fly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an alternative approach that could allow you to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do table='table1','table2','table3' ; /* Specify your list of tables */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rc = open(table);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (not rc) then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m=sysmsg();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put m;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* .... Some Other SAS Statements ....*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rc=close(rc);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Ahmed&lt;/P&gt;</description>
    <pubDate>Wed, 23 Sep 2015 09:32:14 GMT</pubDate>
    <dc:creator>AhmedAl_Attar</dc:creator>
    <dc:date>2015-09-23T09:32:14Z</dc:date>
    <item>
      <title>Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226863#M40856</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently using hash objects to join tables and I would like to loop through 5 tables (e.g. Table_2010, ..., Table_2015) inside my DATA step. To do that, I would like to concatenante the loop counter with a string, let's say "Table_".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My progress so far is the following :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TABLE_2010;
   INPUT ID VAL;
   DATALINES;
1  63
2  22
3  71
;
RUN;&lt;BR /&gt; 
DATA TABLE_2011;
   INPUT ID VAL;
   DATALINES;
4  68
5  55
6  54
;
RUN;
 
DATA RES;
DO i = 2010 TO 2011;
	DO UNTIL (EOF) ;
		SET 'TABLE_'&amp;amp;i END = EOF;
		OTHER_VAL = CATS('TEST',i);
		OUTPUT;
	END;
END;
STOP;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code doesn't currently work (otherwise I wouldn't be posting here) and I can see at least 3 issues :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If I run this, the first&amp;nbsp;error in the log indicates&amp;nbsp;&lt;SPAN&gt;"Apparent symbolic reference i&amp;nbsp;not resolved."&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;The loop looks like it stops after 2010, I suspect EOF is the cause of this and should be replaced by EOF_2010 and EOF_2011.&lt;/LI&gt;&lt;LI&gt;I'm not sure wheter STOP; instruction should be put before or after the END; of the outside loop.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Replacing "TABLE_&amp;amp;i" with CATS("TABLE_",i) doesn't work either ("Invalid option name "TABLE_" error).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am kind of lost here and any help would be appreciated :).&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 14:41:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226863#M40856</guid>
      <dc:creator>sasanon1664</dc:creator>
      <dc:date>2015-09-23T14:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226864#M40857</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To mu knowledge, the SET statement is executed at compilation time, therefore you can not just change the table name on the fly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an alternative approach that could allow you to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do table='table1','table2','table3' ; /* Specify your list of tables */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rc = open(table);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (not rc) then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m=sysmsg();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put m;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* .... Some Other SAS Statements ....*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rc=close(rc);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 09:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226864#M40857</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2015-09-23T09:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226869#M40859</link>
      <description>&lt;P&gt;Let´s dig a little into how the SAS interpreter works:&lt;/P&gt;&lt;P&gt;- program text is gathered&lt;/P&gt;&lt;P&gt;- if a macro reference (¨&amp;amp;¨or ¨%¨)is encountered, text is handed over to the macro processor&lt;/P&gt;&lt;P&gt;- if text for a data step is encountered, the data step is compiled and&lt;/P&gt;&lt;P&gt;- executed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So your &amp;amp;i is handed over to the macro processor LONG before the data step even starts to run, and would need for the macro variable i to already be defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, as alreay mentioned, theSET statement within a data step can not be done dynamically. The reason is that the table named in the SET has a major influence on the data structures present in the data step, which are determined at compile time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make your step dynamic, I suggest the following:&lt;/P&gt;&lt;P&gt;%macro dynamic_sets;&lt;/P&gt;&lt;P&gt;data res;&lt;/P&gt;&lt;P&gt;set&lt;/P&gt;&lt;P&gt;%do i = 2010 %to 2011;&lt;/P&gt;&lt;P&gt;&amp;nbsp; table_&amp;amp;i (in=in&amp;amp;i)&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;%do i = 2010 %to 2011;&lt;/P&gt;&lt;P&gt;if in&amp;amp;i then other_val = ¨test&amp;amp;i¨;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%dynamic_sets;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 10:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226869#M40859</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-09-23T10:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226871#M40861</link>
      <description>&lt;P&gt;Could you post test data and required output. &amp;nbsp;Its not entirely clear to me what your attempting to do here, why can you not use indsname for this?&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; length store $20;&lt;BR /&gt;&amp;nbsp; set table_: indsname=dsname;&lt;BR /&gt;&amp;nbsp; store=scan(dsname,2,".");&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 10:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226871#M40861</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-23T10:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226894#M40863</link>
      <description>&lt;P&gt;The way you have it set up isn't logically correct.&amp;nbsp; Here it is broken down into two steps.&amp;nbsp; Hope this helps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA TABLE_2010;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INPUT ID VAL;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATALINES;&lt;BR /&gt;1&amp;nbsp; 63&lt;BR /&gt;2&amp;nbsp; 22&lt;BR /&gt;3&amp;nbsp; 71&lt;BR /&gt;;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;DATA TABLE_2011;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INPUT ID VAL;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATALINES;&lt;BR /&gt;4&amp;nbsp; 68&lt;BR /&gt;5&amp;nbsp; 55&lt;BR /&gt;6&amp;nbsp; 54&lt;BR /&gt;;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;%macro first;&lt;BR /&gt;%do i = 2010 %to 2011;&lt;BR /&gt;data table_&amp;amp;i;&lt;BR /&gt;set table_&amp;amp;i;&lt;BR /&gt;other_val = "test_&amp;amp;i";&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%first;&lt;BR /&gt;&lt;BR /&gt;data final;&lt;BR /&gt;%macro second;&lt;BR /&gt;set&lt;BR /&gt;&lt;BR /&gt;%do i = 2010 %to 2011;&lt;BR /&gt;&amp;nbsp;table_&amp;amp;i&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%second;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would recommend writting this out long hand and seeing what you can do without macros first.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 13:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226894#M40863</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-09-23T13:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226900#M40864</link>
      <description>&lt;P&gt;Thank you everyone for your answers, especially Kurt for the explanation on how things work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I feel like I should provide a more complete code and here it is :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SMALL;
   INPUT ID NAME $;
   DATALINES;
1 Red
2 Green
3 Blue
;
RUN;&lt;BR /&gt;
DATA TABLE_2010;
   INPUT ID YEAR VAL;
   DATALINES;
1 2010 63
2 2010 22
3 2010 71

;
RUN;&lt;BR /&gt;
DATA TABLE_2011;
   INPUT ID YEAR VAL;
   DATALINES;
1 2011 68
2 2011 55
3 2011 54
;
RUN;

DATA WANT (drop = rc);

	declare hash h (hashexp:16);
	rc = h.DefineKey ('ID');
	rc = h.DefineData ('NAME');
	rc = h.DefineDone ();

	do until (eof1);
		set SMALL end = eof1;
		rc = h.add ();
	end;

	DO UNTIL (EOF_2010) ;
		SET TABLE_2010 END = EOF_2010;
		CALL MISSING(NAME);
		rc = h.find ();
		OUTPUT;
	END;

	DO UNTIL (EOF_2011) ;
		SET TABLE_2011 END = EOF_2011;
		CALL MISSING(NAME);
		rc = h.find ();
		OUTPUT;
	END;

STOP;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This part works as intended but my goal is to go through TABLE_2010 and TABLE_2011 without having to write the same code (DO UNTIL... END;) twice in this case. That's why some of the suggestions won't work, because their alter my code too much for what I want to do. I think I can't wrap everything in a macro because it will load the SMALL table in memory twice, which I am trying to avoid (there are actually more like 20 tables loaded and some of them are over 100 000 rows). The yearly tables are about 1M rows each.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this makes things clearer for you.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 14:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226900#M40864</guid>
      <dc:creator>sasanon1664</dc:creator>
      <dc:date>2015-09-23T14:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226903#M40867</link>
      <description>&lt;P&gt;Write this macro:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO one_table(year);
DO UNTIL (EOF_&amp;amp;year) ;
  SET TABLE_&amp;amp;year END = EOF_&amp;amp;year;
  CALL MISSING(NAME);
  rc = h.find ();
  OUTPUT;
END;
%MEND;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and call it for every year:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%one_table(2010)
%one_table(2011)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or use a macro %do loop within the macro to repeat the code.&lt;/P&gt;&lt;P&gt;This is what the macro engine is for.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 13:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226903#M40867</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-09-23T13:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226906#M40868</link>
      <description>&lt;P&gt;Nope, I am sorry, I still do not see the point of all that code. &amp;nbsp;What you are outputting is a union of the second and third dataset merged with the first. &amp;nbsp;This can be simply written as:&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table WANT2 as&lt;BR /&gt;&amp;nbsp; select A.*,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B.NAME&lt;BR /&gt;&amp;nbsp; from (select * from TABLE_2010 union all select * from TABLE_2011) A&lt;BR /&gt;&amp;nbsp; left join SMALL B&lt;BR /&gt;&amp;nbsp; on A.ID=B.ID&lt;BR /&gt;&amp;nbsp; order by YEAR,ID;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please also note that writing everything in uppercase and not finishing datasteps makes your code harder to read.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 13:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226906#M40868</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-23T13:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226913#M40869</link>
      <description>&lt;P&gt;Thank you Kurt, this solution seems to be working on my example, I will try to make it work in my code :). One question though : is it wrong to write the entire macro inside the data step or should I only call it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for RW9's suggestion, my point is to avoid using SQL joins because they take way too much&amp;nbsp;of time compared to joining using hash objects. Why should I do something in one hour when it can be done in two minutes (those are real numbers)? Moreover, thank you for pointing out that I forgot to finish my datasteps, I will correct them. As for writing in uppercase, I would gladly take any directions&amp;nbsp;on what to write in upper/lowercase because I have no knowledge&amp;nbsp;on that matter.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 15:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226913#M40869</guid>
      <dc:creator>sasanon1664</dc:creator>
      <dc:date>2015-09-23T15:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226920#M40870</link>
      <description>&lt;P&gt;Just use datastep version then:&lt;/P&gt;&lt;P&gt;data inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set table:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge inter small;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for GPP, its something you will see on a lot of code here. &amp;nbsp;Avoid using upper case (except SQL) as its harder to read. &amp;nbsp;Finishing datasteps, consistent indents using spaces rather than tabs (although the forum here is bad for code formatting). &amp;nbsp;Just helps reading code &lt;span class="lia-unicode-emoji" title=":monkey_face:"&gt;🐵&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 15:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/226920#M40870</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-23T15:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving loop counter inside a DATA step without using MACRO.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/227043#M40877</link>
      <description>&lt;P&gt;Thank you for the tips RW9, they are duly noted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also advise you to read the followings articles which compare hash tables vs SQL joins vs merge :&amp;nbsp;&lt;A href="http://support.sas.com/resources/papers/proceedings09/071-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/071-2009.pdf&lt;/A&gt; and&amp;nbsp;&lt;A href="http://www2.sas.com/proceedings/sugi31/244-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/244-31.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 10:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-loop-counter-inside-a-DATA-step-without-using-MACRO/m-p/227043#M40877</guid>
      <dc:creator>sasanon1664</dc:creator>
      <dc:date>2015-09-24T10:13:38Z</dc:date>
    </item>
  </channel>
</rss>

