<?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: BASE SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378568#M91011</link>
    <description>&lt;P&gt;This isn't an easy problem to solve by the way, so it's an interesting problem from that perspective. It looks like a recursive chain look up and I think you can use the macro here. From a graph theory lens, it's asking to identify each branch.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or search 'recursive lookup' on here and you'll find some hash solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2017 00:43:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-07-24T00:43:55Z</dc:date>
    <item>
      <title>BASE SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378550#M90996</link>
      <description>&lt;P&gt;Hi below is the interview question which I faced,we can solve it by hardcoding ,can we solve it without hard coding. pls help me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An exposure is linked to a limit. And a limit can have multiple exposures associated to it. Similarly a limit may have multiple collateral associated to it. Collateral can be shared between multiple limits. Please see the below sample input dataset,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P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&gt;&lt;TD&gt;&lt;P&gt;C5&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;7&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;L4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C6&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;8&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;L5&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C5&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are given the task to write code and generate below output, to cluster the related exposure, limit and collateral together with a ClusterId.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;ExposureId&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;LimitId&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;CollateralId&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;ClusterId&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;L1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;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6&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;8&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;L5&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C5&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sun, 23 Jul 2017 18:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378550#M90996</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2017-07-23T18:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: BASE SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378566#M91010</link>
      <description>Could you please provide more details of the exposure limits. How the exposure limit is linked with the collateralid</description>
      <pubDate>Mon, 24 Jul 2017 00:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378566#M91010</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-07-24T00:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: BASE SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378568#M91011</link>
      <description>&lt;P&gt;This isn't an easy problem to solve by the way, so it's an interesting problem from that perspective. It looks like a recursive chain look up and I think you can use the macro here. From a graph theory lens, it's asking to identify each branch.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or search 'recursive lookup' on here and you'll find some hash solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 00:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378568#M91011</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-24T00:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: BASE SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378680#M91068</link>
      <description>&lt;PRE&gt;I have answered this question before. Isn't it you ? 
Here  could give you a start. Once you got WANT table. It is easy to  get what you want.







data have;
infile cards ;
input from $  to $ ;
cards;
1     2
1     3
4     5
5     2
9     4
6     7
8     7
;
run;
data full;
  set have end=last;
  if _n_ eq 1 then do;
   declare hash h();
    h.definekey('node');
     h.definedata('node');
     h.definedone();
  end;
  output;
  node=from; h.replace();
  from=to; to=node;
  output;
  node=from; h.replace();
  if last then h.output(dataset:'node');
  drop node;
run;


data want(keep=node household);
declare hash ha(ordered:'a');
declare hiter hi('ha');
ha.definekey('count');
ha.definedata('last');
ha.definedone();
declare hash _ha(hashexp: 20);
_ha.definekey('key');
_ha.definedone();

if 0 then set full;
declare hash from_to(dataset:'full(where=(from is not missing and to is not missing))',hashexp:20,multidata:'y');
 from_to.definekey('from');
 from_to.definedata('to');
 from_to.definedone();

if 0 then set node;
declare hash no(dataset:'node');
declare hiter hi_no('no');
 no.definekey('node');
 no.definedata('node');
 no.definedone();
 

do while(hi_no.next()=0);
 household+1; output;
 count=1;
 key=node;_ha.add();
 last=node;ha.add();
 rc=hi.first();
 do while(rc=0);
   from=last;rx=from_to.find();
   do while(rx=0);
     key=to;ry=_ha.check();
      if ry ne 0 then do;
       node=to;output;rr=no.remove(key:node);
       key=to;_ha.add();
       count+1;
       last=to;ha.add();
      end;
      rx=from_to.find_next();
   end;
   rc=hi.next();
end;
ha.clear();_ha.clear();
end;
stop;
run;





&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 13:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378680#M91068</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-24T13:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: BASE SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378937#M91132</link>
      <description>&lt;P&gt;I dont have knowledge of hash tables,its abit difficult to understand,cud u pls brief me what is happening there actually&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 12:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378937#M91132</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2017-07-25T12:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: BASE SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378941#M91134</link>
      <description>&lt;P&gt;NO. I am not going to talk about Hash Table here. It is a very big topic.&lt;/P&gt;
&lt;P&gt;If you don't know anything about it ,check its documention at support.sas.com&amp;nbsp; .&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 12:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BASE-SAS/m-p/378941#M91134</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-25T12:19:06Z</dc:date>
    </item>
  </channel>
</rss>

