<?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 Need Asistance DI Studio: Max Effective Date Subquery in Join Transformation. in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401421#M12202</link>
    <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have hit a wall trying to implement something i do all day long in EG.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are using DI studio 4.901. I am attempting to build a job that requires the data to be max effectie dated before loading to its final destination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am lost on how to make this happen in the subquery transformation. I have attempted multiple ways and am unable to make it happen sucessfully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any assitance on simply where i need to put the Subquery code and build the job links would be greatly apreciated.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2017 16:12:13 GMT</pubDate>
    <dc:creator>smilbuta</dc:creator>
    <dc:date>2017-10-05T16:12:13Z</dc:date>
    <item>
      <title>Need Asistance DI Studio: Max Effective Date Subquery in Join Transformation.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401421#M12202</link>
      <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have hit a wall trying to implement something i do all day long in EG.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are using DI studio 4.901. I am attempting to build a job that requires the data to be max effectie dated before loading to its final destination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am lost on how to make this happen in the subquery transformation. I have attempted multiple ways and am unable to make it happen sucessfully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any assitance on simply where i need to put the Subquery code and build the job links would be greatly apreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 16:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401421#M12202</guid>
      <dc:creator>smilbuta</dc:creator>
      <dc:date>2017-10-05T16:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need Asistance DI Studio: Max Effective Date Subquery in Join Transformation.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401482#M12203</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19508"&gt;@smilbuta&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The SQL JOIN transformation allows you to define sub-queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do? Is this about loading into a table using SCD2?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And alternative to a sub-query can be to define first a SQL view as a "green table" (using the SQL JOIN or SQL EXTRACT transformation) and then join this view back to your source table using a 2nd SQL JOIN transformation.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 18:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401482#M12203</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-05T18:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need Asistance DI Studio: Max Effective Date Subquery in Join Transformation.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401495#M12204</link>
      <description>&lt;P&gt;Hi Patrick,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was able to Sucsessfuly do wat i wanted to do in the SQL Execute node via user written code. But i was trying to be more savy and learn how to do it properly in the Join step as many have advised to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am simply&amp;nbsp;missing something with regards to how to build the join with a Subquery to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To bad i cant upload a screen grab of my job.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My currently working code is as follows:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SOURCETABLE -&amp;gt; EXTRACT -&amp;gt; SQL Execute(max effecive date) -&amp;gt; Other Transformations until Table loader.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What i was trying to do:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SOURCETABLE -&amp;gt; EXTRACT -&amp;gt; SUBQUERY (with max effective date) -&amp;gt; JOIN -&amp;gt; Other Transformations until Table loader.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could not figure out how to build the the subquery correctly to interface with the Join. Im missing some key element here.&lt;/P&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;</description>
      <pubDate>Thu, 05 Oct 2017 19:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401495#M12204</guid>
      <dc:creator>smilbuta</dc:creator>
      <dc:date>2017-10-05T19:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need Asistance DI Studio: Max Effective Date Subquery in Join Transformation.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401648#M12205</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19508"&gt;@smilbuta&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Share your user written code. This will explain to us the logic you want to implement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add screen shots via:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Take screenshot/snip and store it&lt;/P&gt;
&lt;P&gt;2. Use the "Photos" icon here and upload the screenshot to the forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also add attachments via the icon next to "Photos".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't seen your code yet but from what you describe a simple group by statement&amp;nbsp;using the SQL JOIN transformation could eventually already do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ata source;
  do group='A','B','C';
    do id=1 to 5;
      format effective_date date9.;
      effective_date=today()-ceil(ranuni(1)*100);
      output;
    end;
  end;
run;

proc sql;
  create table want as
    select 
      *,
      max(effective_date) as max_grouup_effective_date format=date9.
    from source
    group by group
    order by group, id
    ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 08:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401648#M12205</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-06T08:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need Asistance DI Studio: Max Effective Date Subquery in Join Transformation.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401657#M12206</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19508"&gt;@smilbuta&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;To generate code in DIS as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.Target as
   select
      source_for_subselect.Id length = 8,
      source_for_subselect.Group length = 8,
      source_for_subselect.effective_date length = 8   
         format = date9.,
      max_group_effective_date length = 8   
         format = date9.
   from
      tests.source_for_subselect as source_for_subselect, 
      (
         select
            source_for_subselect_i.Group length = 8,
            source_for_subselect_i.effective_date as max_group_effective_date length = 8   
               format = date9.
         from
            tests.source_for_subselect as source_for_subselect_i
         group by
            source_for_subselect_i.Group
      )
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your flow needs to look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 354px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15649i15F3A1E2ABD58FB7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15650i5D0BA6809C610CDF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15651i1AD2D9F3A4F6E858/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally find sub-selects in DIS too labor intensive to implement and even more importantly I don't like how deep the logic gets hidden in the transformation and that I can't see "everything" visually at once.&lt;/P&gt;
&lt;P&gt;For this reason I normally don't implement using sub-selects but I'm using two SQL joins and my job flow would look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 558px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15653iAB04660FA3A8018B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The code generated by the Join node looks then like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.Target as
   select
      source_for_subselect.Id length = 8,
      source_for_subselect.Group length = 8,
      source_for_subselect.effective_date length = 8   
         format = date9.,
      max_eff_dt.max_group_effective_date length = 8   
         format = date9.
   from
      tests.source_for_subselect as source_for_subselect, 
      work.max_eff_dt as max_eff_dt
   where
      source_for_subselect.Group = max_eff_dt.Group
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've created source &lt;EM&gt;work.max_eff_dt&lt;/EM&gt; as a view with a definition of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create view work.max_eff_dt as
      select
         Group,
         (max(effective_date)) as max_group_effective_date length = 8
            format = date9.
   from &amp;amp;SYSLAST
   order by
      Group
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Given that a view can be seen as encapsulated SQL code which only gets executed when used.... if you compare what the flow using a sub-select generates as code with what my 2nd approach creates then you'll see that this is basically the same code when it comes to execution time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally find the 2nd option easier to implement and much easier to "read" and maintain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 23:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Need-Asistance-DI-Studio-Max-Effective-Date-Subquery-in-Join/m-p/401657#M12206</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-08T23:23:43Z</dc:date>
    </item>
  </channel>
</rss>

