<?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: Recursive Query in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467013#M14595</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;right. Yes, I noticed on a quick google search. Hmm ocean of procs and modules&amp;nbsp;&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://communities.sas.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jun 2018 20:01:24 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-06-01T20:01:24Z</dc:date>
    <item>
      <title>Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861#M14584</link>
      <description>How to construct query for the following expected outpit:-&lt;BR /&gt;&lt;BR /&gt;Source table:-&lt;BR /&gt;Cust_id.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P_cust_id&lt;BR /&gt;111.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;222.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 111&lt;BR /&gt;333.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 222&lt;BR /&gt;444.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 333&lt;BR /&gt;555.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 444&lt;BR /&gt;&lt;BR /&gt;Expected result:-&lt;BR /&gt;Cust_id.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expected_cust_id&lt;BR /&gt;111.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 555&lt;BR /&gt;222.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 555&lt;BR /&gt;333.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 555&lt;BR /&gt;444.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 555&lt;BR /&gt;111.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 444&lt;BR /&gt;222.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 444&lt;BR /&gt;333.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 444&lt;BR /&gt;111.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 333&lt;BR /&gt;222.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 333&lt;BR /&gt;111.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 222</description>
      <pubDate>Fri, 01 Jun 2018 14:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861#M14584</guid>
      <dc:creator>IvyHeng88</dc:creator>
      <dc:date>2018-06-01T14:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466882#M14586</link>
      <description>&lt;P&gt;Is the logic that each P_cust_id to be paired with the other cust_id and cust_id is less than P_cust_id? If not explain the logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 15:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466882#M14586</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-01T15:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466886#M14587</link>
      <description>&lt;P&gt;Do you have dates attached at all? If you do it becomes a bit easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a macro here that will group the ID's , exp=8 means that it looks for a max of 8 depth. If you need further you can increase it, but the slower it gets. Once it groups the ID, if you have a date, you can take the latest ID and then you'll have a master table of IDs that you can then merge with SQL.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro SubGraphs(arcs,from=from,to=to,out=Clusters,exp=8);
data _null_;
if 0 then set &amp;amp;arcs(keep=&amp;amp;from rename=(&amp;amp;from=node)); /* get node data type */
length clust 8;
declare hash nodes(hashexp:&amp;amp;exp);
nodes.defineKey('node');
nodes.defineData('node', 'clust');
nodes.defineDone();
declare hiter nodeList('nodes');

do newClust = 1 by 1 while(not endLoop);
	set &amp;amp;arcs end=endLoop;
	call missing(clust); node = &amp;amp;from;
	if 0^=nodes.find() then nodes.add(); 
	fromClust = clust; 
	call missing(clust); node = &amp;amp;to;
	if 0^=nodes.find() then nodes.add(); 
	toClust = clust;
	if n(fromClust, toClust) = 0 then do;
		nodes.replace(key:&amp;amp;from, data:&amp;amp;from, data:newClust);
		nodes.replace(key:&amp;amp;to, data:&amp;amp;to, data:newClust);
	end;
	else if missing(toClust) then 
		nodes.replace(key:&amp;amp;to, data:&amp;amp;to, data:fromClust);
	else if missing(fromClust) then 
		nodes.replace(key:&amp;amp;from, data:&amp;amp;from, data:toClust);
	else if fromClust ne toClust then do;
		rc = nodeList.first();
		do while (rc = 0);
			if clust = fromClust then 
				nodes.replace(key:node, data:node, data:toClust);
			rc = nodeList.next();
		end;
	end;
end;
nodes.output(dataset:"&amp;amp;out");
stop;
run;
%mend SubGraphs;

data have;
infile cards dlm='.' truncover;
input Cust_id     P_cust_id;
cards;
222.           111
333.           222
444.           333
555.           444
;
run;



%SubGraphs(have,from=p_cust_id,to=cust_id,out=Clusters,exp=5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/14e3aa2a9f718f551cd98134e9ceed30" target="_blank"&gt;https://gist.github.com/statgeek/14e3aa2a9f718f551cd98134e9ceed30&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 15:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466886#M14587</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-01T15:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466903#M14588</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Cust_id   P_cust_id) ($);
cards;
111            .
222           111
333           222
444           333
555           444
;

proc sql;
create table temp as
select a.Cust_id,b.P_cust_id
from have a, have b;
quit;

data _null_;
if _n_=1 then do;
 dcl hash H (ordered: "d",multidata:'y') ;
   h.definekey  ("Cust_id") ;
   h.definedata ('Cust_id',"p_cust_id") ;
   h.definedone () ;
end;
_grp+1;
do _n=1 by 1 until(last.cust_id);
set temp end=last;
by cust_id;
where not missing(P_cust_id);
if _n&amp;lt;=_grp-1 then h.add();
end;
if last then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 16:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466903#M14588</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-01T16:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466925#M14589</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, exp=8&amp;nbsp;in the SubGraphs macro call&amp;nbsp;is the power of two that determines the size of the hash table, 2^8 = 256 here. There is no limit to the search depth.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 16:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466925#M14589</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-01T16:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466927#M14590</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt; Thanks! &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213168"&gt;@IvyHeng88&lt;/a&gt; This is originally PGStats code as noted in the link.</description>
      <pubDate>Fri, 01 Jun 2018 16:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466927#M14590</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-01T16:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466968#M14592</link>
      <description>&lt;P&gt;Here's a similar example using PROC BOM:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ParComp0;
infile datalines dlm='09'x;
length Parent $ 4 Component $ 4;
input Parent Component QtyPer;
cards;
LA01	B100	1
LA01	S100	1
LA01	A100	1
B100	1100	1
B100	1200	1
B100	1300	1
B100	1400	4
A100	1500	1
A100	1600	1
A100	1700	1
1100	2100	26
1500	1400	2
1700	2200	12
1700	2300	1
run;
data PMaster0;
infile datalines dlm='09'x;
length Part $ 4 Desc $ 32 Unit $ 12;
input Part Desc Unit;
cards;
1100	Finished shaft	Each
1200	6-Diameter steel plate	Each
1300	Hub	Each
1400	1/4-20 Screw	Each
1500	Steel holder	Each
1600	One-way socket	Each
1700	Wiring assembly	Each
2100	3/8 Steel tubing	Inches
2200	16-Gauge lamp cord	Feet
2300	Standard plug terminal	Each
A100	Socket assembly	Each
B100	Base assembly	Each
LA01	Lamp LA	Each
S100	Black shade	Each
run;

/* Create the indented BOM and summarized parts list */
proc bom data=ParComp0 pmdata=PMaster0 
         out=IndBOM0 summaryout=SumBOM0; 
   structure / part=Part 
               parent=Parent
               component=Component
               quantity=QtyPer
               id=(Desc Unit);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 18:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466968#M14592</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-06-01T18:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466969#M14593</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15142"&gt;@TomKari&lt;/a&gt;&amp;nbsp; &amp;nbsp;Blimey, that shows learning sas can be a never ending process. Nice and Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 18:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466969#M14593</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-01T18:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467011#M14594</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;PROC BOM requires SAS/OR which isn't installed in a lot of SAS installations.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 19:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467011#M14594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-01T19:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467013#M14595</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;right. Yes, I noticed on a quick google search. Hmm ocean of procs and modules&amp;nbsp;&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://communities.sas.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 20:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467013#M14595</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-01T20:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467035#M14596</link>
      <description>&lt;P&gt;If there is a unique p_cust_id for any cust_id then you can go up the chain in a simple way by indexing your dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Cust_id   P_cust_id) ($);
cards;
111            .
222           111
333           222
444           333
555           444
;

proc sql;
create unique index cust_id on have (cust_id);
quit;

data want;
set have;
Expected_cust_id = cust_id;
do while(not missing(p_cust_id));
    output;
    cust_id = p_cust_id;
    set have key=cust_id/unique;
    if _IORC_ ne 0 then leave;
    end;
_error_ = 0;
rename p_cust_id=cust_id;
drop cust_id;
run;

proc print data=want noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 20:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467035#M14596</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-01T20:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467041#M14597</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Cust_id   P_cust_id) ($);
cards;
111            .
222           111
333           222
444           333
555           444
;
data _null_;
if _n_=1 then do;
 dcl hash H (ordered: "d",multidata:'y') ;
   h.definekey  ("Cust_id") ;
   h.definedata ('Cust_id',"p_cust_id") ;
   h.definedone () ;
end;
set have(keep=cust_id) end=last;
_grp+1;
do n=1 to nobs ;
_k=n-1;
set have(keep=p_cust_id) point=n nobs=nobs;
if _k and  _k&amp;lt;=_grp-1 then h.add();
end;
if last then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 21:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467041#M14597</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-01T21:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467108#M14598</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Cust_id   P_cust_id) ($);
n+1;
cards;
111            .
222           111
333           222
444           333
555           444
;
data want;
 if 0 then set have;
 declare hash h() ;
   h.definekey  ("p_cust_id") ;
   h.definedata ("Cust_id") ;
   h.definedone ();
 declare hash hh(dataset:'have',ordered:'y');
 declare hiter hi('hh');
   hh.definekey('n');
   hh.definedata("Cust_id","p_cust_id");
   hh.definedone();

do n=hh.num_items to 1 by -1;
h.clear();
rc=hi.first();
do while(rc=0);
  h.add();
  rc=hi.next();
end;

hh.remove();
rc=hi.first();
do while(rc=0);
  _Cust_id=Cust_id;
  rx=h.check(key:Cust_id);
  do while(h.find(key:Cust_id)=0);
  end;
  if rx ne 0 then call missing(_p_cust_id);
   else _p_cust_id=Cust_id;output; 
  rc=hi.next();
end;
end;
keep _: ;
run;

proc print noobs;run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Jun 2018 11:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467108#M14598</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-06-02T11:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467150#M14599</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;, your program generates these notes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric
      values at the places given by: (Line):(Column).
      39:20
NOTE: There were 5 observations read from the data set WORK.HAVE.
NOTE: DATA STEP stopped due to looping.
NOTE: The data set WORK.WANT has 10 observations and 2 variables.
&lt;/PRE&gt;
&lt;P&gt;Under SAS 9.4 TS Level 1M5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jun 2018 19:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467150#M14599</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-02T19:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467197#M14600</link>
      <description>&lt;P&gt;And yet another hash variation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=_: rename=(cust_id=Expected_cust_id p_cust_id=cust_id));
  if _n_=1 then
    do;
      dcl hash h1(dataset:'have(where=(not missing(p_cust_id)))' );
      h1.defineKey('p_cust_id');
      h1.defineData('cust_id');
      h1.defineDone();
    end;
  set have(where=(not missing(p_cust_id)));
  output;
  /* lookup children, counter loop added to avoid endless loops in case of DQ issues */
  do _i=1 to 10000 while(h1.find(key:cust_id)=0);
    output;
  end;
  if _i&amp;gt;=10000 then 
    do;
      putlog "DQ issues found leading to endless loop";
      putlog "Source record is: " _n_ 10. -l;
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jun 2018 03:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467197#M14600</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-03T03:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467218#M14601</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;That is just NOTE not WARNING.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe should try this to get rid of this kind of NOTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Cust_id   P_cust_id&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
111            .
222           111
333           222
444           333
555           444
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jun 2018 12:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467218#M14601</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-06-03T12:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive Query</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467287#M14605</link>
      <description>Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;, awesome simple and straight forward ^_^</description>
      <pubDate>Mon, 04 Jun 2018 03:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/467287#M14605</guid>
      <dc:creator>IvyHeng88</dc:creator>
      <dc:date>2018-06-04T03:24:28Z</dc:date>
    </item>
  </channel>
</rss>

