<?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: Looping issue while update target tables based on the previous dataset names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641672#M191296</link>
    <description>&lt;P&gt;There is no rule for company code. I just want to get the table names and table count from the datasets which was created before&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2020 16:32:07 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2020-04-21T16:32:07Z</dc:date>
    <item>
      <title>Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641660#M191288</link>
      <description>&lt;PRE&gt;data details;
infile datalines truncover;
input Run_ID :$5. Company_code :$3. Datasource :$10. Table_name :$10. table_count;
datalines;
12345 ABC Database   
12345 ABD Database   
12345 ABE Database   
12345 ABF Database   
12346 DEF Excel
;

data insurance;
input Run_ID :$5. Table_name :$10. Table_count;
datalines;
12345 Insurance 87
;

data insurancf;
input Run_ID :$5. Table_name :$10. Table_count;
datalines;
12345 Insurancf 870
;

data insurancg;
input Run_ID :$5. Table_name :$10. Table_count;
datalines;
12345 Insurancg 8700
;

data insuranch;
input Run_ID :$5. Table_name :$10. Table_count;
datalines;
12345 Insuranch 87000
;

%macro update(table);
proc sql;
update details a
  set
    table_name = (select table_name from &amp;amp;table. b where a.run_id = b.run_id),
    table_count = (select table_count from &amp;amp;table. b where a.run_id = b.run_id)
  where a.run_id in (select run_id from &amp;amp;table.)
;
quit;
%mend;

data _null_;
input tablename $32.;
call execute(cats('%nrstr(%update(',tablename,'))'));
datalines;
Insurance
Insurancf
Insurancg
Insuranch
;
run;&lt;/PRE&gt;
&lt;P&gt;I've the code as above. If you look at the last data_null_&amp;nbsp;I have given the values of dataset names which was created before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in the real life it may create any number of datasets and so I don't want to hard code the dataset names instead I would like to pass the macro variables which has the values of dataset names&amp;nbsp;as Input to call execute so that it will run for each of the Input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here one hint which we can utilize is, Input names will comes under any of these five names or all five (Insurance,Insuarncd,Insurance,Insurancef,Insuaranceg)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excepted Output is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="width: 270pt; border-collapse: collapse;" border="0" width="360" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 54pt;" span="5" width="72" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="72" height="20" style="border: 0.5pt solid windowtext; width: 54pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Run_ID&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Company_code&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Datasource&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Table_name&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;table_count&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABC&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insurance&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;87&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABD&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insurancf&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;870&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABE&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insurancg&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;8700&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABF&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insuranch&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;87000&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12346&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;DEF&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Excel&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But Output what I got based on my code is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="width: 270pt; border-collapse: collapse;" border="0" width="360" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 54pt;" span="5" width="72" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="72" height="20" style="border: 0.5pt solid windowtext; width: 54pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Run_ID&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Company_code&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Datasource&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Table_name&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;table_count&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABC&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insuranch&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;87000&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABD&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insuranch&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;87000&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABE&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insuranch&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;87000&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12345&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;ABF&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Database&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Insuranch&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;87000&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;12346&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;DEF&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;Excel&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641660#M191288</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T16:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641661#M191289</link>
      <description />
      <pubDate>Tue, 21 Apr 2020 16:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641661#M191289</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T16:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641667#M191292</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your result is 100% expected behaviour, because you have &lt;U&gt;NonUnique&lt;/U&gt; update keys.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try to add table name variable to your basetable(`details`) so you will be able to find 1-to-1 match between "basetable" and the one with count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641667#M191292</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-04-21T16:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641670#M191294</link>
      <description>&lt;P&gt;What is the rule that tells you that the data from insurancf must overwrite company ABD, but not the others? (and so on for the other datasets)&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641670#M191294</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-21T16:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641671#M191295</link>
      <description>&lt;P&gt;Is there a way, please help me with the example or help by tweaking my code?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641671#M191295</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T16:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641672#M191296</link>
      <description>&lt;P&gt;There is no rule for company code. I just want to get the table names and table count from the datasets which was created before&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641672#M191296</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T16:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641675#M191298</link>
      <description>&lt;P&gt;Without a rule, there is no algorithm, and without an algorithm, there can be no code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There is no rule for company code. I just want to get the table names and table count from the datasets which was created before&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641675#M191298</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-21T16:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641679#M191300</link>
      <description>There is a rule as I mentioned in the previous posts. But no rule for&lt;BR /&gt;company code. Why would you except rule for company code? I just need to&lt;BR /&gt;retain the value for company code which was already available in base table&lt;BR /&gt;(details)  as it is same for all records for now.&lt;BR /&gt;&lt;BR /&gt;Can't we tweak the proposed code to get the table names and table count&lt;BR /&gt;dynamically  and insert in base table (details)  without the rule for&lt;BR /&gt;company code?&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2020 17:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641679#M191300</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T17:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641693#M191305</link>
      <description>&lt;P&gt;The only difference between the observations for run_id is in the company_code, so I assumed this to be the deciding factor.&lt;/P&gt;
&lt;P&gt;What then, is the deciding factor that causes the value from (e.g.) insuranch to only overwrite this specific observation it ends up in, and not the others?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 17:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641693#M191305</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-21T17:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641700#M191307</link>
      <description>Well, let me slightly tweak the requirement. How can we handle if the table&lt;BR /&gt;name and company code  is unique? Assume  the table name and company code&lt;BR /&gt;is different for each record.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2020 18:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641700#M191307</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T18:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641703#M191309</link>
      <description>&lt;P&gt;You have not answered my question.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;WHAT IS THE RULE?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 18:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641703#M191309</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-21T18:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641707#M191311</link>
      <description>Rule is simple. Assume two datasets are created called A and B in the&lt;BR /&gt;program  and it has Run_id as one of the field&lt;BR /&gt;&lt;BR /&gt;Assume you also have one base  table (details) which has all the fields as&lt;BR /&gt;I mentioned in the initial post. Field company code is unique.&lt;BR /&gt;&lt;BR /&gt;Now you want to get the dataset name and count of the respective datasets&lt;BR /&gt;(A &amp;amp; B) and update in base table 'details'.&lt;BR /&gt;&lt;BR /&gt;To answer your question, company code value should  be different for A and&lt;BR /&gt;B while we update base table.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2020 18:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641707#M191311</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T18:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641710#M191314</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data details;
infile datalines truncover;
input Run_ID :$5. Company_code :$3. Datasource :$10. Table_name :$10. table_count;
datalines;
12345 ABC Database   
12345 ABD Database   
12345 ABE Database   
12345 ABF Database   
12346 DEF Excel
;

data insurance;
input Company_code :$5. Table_name :$10. Table_count;
datalines;
ABC Insurance 87
;

data insurancf;
input Company_code :$5. Table_name :$10. Table_count;
datalines;
ABD Insurancf 870
;

data insurancg;
input Company_code :$5. Table_name :$10. Table_count;
datalines;
ABE Insurancg 8700
;

data insuranch;
input Company_code :$5. Table_name :$10. Table_count;
datalines;
ABF Insuranch 87000
;

%macro update(table);
proc sql;
update details a
  set
    table_name = (select table_name from &amp;amp;table. b where a.Company_code = b.Company_code),
    table_count = (select table_count from &amp;amp;table. b where a.Company_code = b.Company_code)
  where a.Company_code = (select Company_code from &amp;amp;table.)
;
quit;
%mend;

data _null_;
input tablename $32.;
call execute(cats('%nrstr(%update(',tablename,'))'));
datalines;
Insurance
Insurancf
Insurancg
Insuranch
;
run;

proc print data = details;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Apr 2020 18:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641710#M191314</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-04-21T18:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641712#M191316</link>
      <description>&lt;P&gt;You still have not explained why (to follow your initial example) the data from insuranch goes into the 4th observation for run_id 12345, and not into the first, second or third.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 18:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641712#M191316</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-21T18:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641783#M191348</link>
      <description>That's a dummy data and I forgot to change the company code for each of the&lt;BR /&gt;table_name.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2020 23:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641783#M191348</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T23:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641785#M191350</link>
      <description>What if I use both run_id and company code for the join condition?&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2020 23:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641785#M191350</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-04-21T23:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping issue while update target tables based on the previous dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641987#M191455</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data details;
infile datalines truncover;
input Run_ID :$5. Company_code :$3. Datasource :$10. Table_name :$10. table_count;
datalines;
12345 ABC Database   
12345 ABD Database   
12345 ABE Database   
12345 ABF Database   
12346 DEF Excel
;

data insurance;
input Run_ID :$5. Company_code :$5. Table_name :$10. Table_count;
datalines;
12345 ABC Insurance 87
;

data insurancf;
input Run_ID :$5. Company_code :$5. Table_name :$10. Table_count;
datalines;
12345 ABD Insurancf 870
;

data insurancg;
input Run_ID :$5. Company_code :$5. Table_name :$10. Table_count;
datalines;
12345 ABE Insurancg 8700
;

data insuranch;
input Run_ID :$5. Company_code :$5. Table_name :$10. Table_count;
datalines;
12345 ABF Insuranch 87000
;

%macro update(table);
proc sql;
update details a
  set
    table_name = (select table_name from &amp;amp;table. b 
                  where a.Company_code = b.Company_code
                    and a.Run_ID = b.Run_ID),
    table_count = (select table_count from &amp;amp;table. b 
                   where a.Company_code = b.Company_code
                    and a.Run_ID = b.Run_ID)
  where a.Company_code = (select Company_code from &amp;amp;table.)
;
quit;
%mend;

data _null_;
input tablename $32.;
call execute(cats('%nrstr(%update(',tablename,'))'));
datalines;
Insurance
Insurancf
Insurancg
Insuranch
;
run;

proc print data = details;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 15:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-issue-while-update-target-tables-based-on-the-previous/m-p/641987#M191455</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-04-22T15:10:12Z</dc:date>
    </item>
  </channel>
</rss>

