<?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: How to 'find' a Dataset in a library and do a matching look up conditionally? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-Dataset-in-a-library-and-do-a-matching-look-up/m-p/201843#M305977</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears that you are doing this for a specified customer id. If so something like this might be a workable start:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro DoCompare(id= );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %sysfunc(exist(libref.final_output_past_&amp;amp;id)) %then %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;lt;here would go the code for when the file exists&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %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;lt;whatever you do when it isn't found&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And call using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%DoCompare(id=&amp;amp;customer_id);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Aug 2015 19:24:59 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-08-18T19:24:59Z</dc:date>
    <item>
      <title>How to 'find' a Dataset in a library and do a matching look up conditionally?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-Dataset-in-a-library-and-do-a-matching-look-up/m-p/201842#M305976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Folks, I am in need of a solution that should do a look up for an equivalent dataset that is named past as opposed to the current output being named present.&amp;nbsp; I have a daily, weekly and monthly ETL SAS process that typically extracts data from multiple sources into a dataset. After certain, validation and transformation I am coping the final output in a folder or in other words library to have it permanently stored. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final output I get after each run is named as &lt;STRONG&gt;Present&lt;/STRONG&gt; and have added a suffix using a macro variable that I take Customer_ID value from the dataset. This is done to make it a unique named dataset so that when the process is run everytime a new dataset gets stored in the library. So for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data libref.final_output_&lt;STRONG&gt;present&lt;/STRONG&gt;_&lt;STRONG&gt;&amp;amp;customer_id&lt;/STRONG&gt;;&amp;nbsp;&amp;nbsp; /*in this example: Permanent library is libref and &amp;amp;customer_id will resolve as the unique identifier for the dataset*/&lt;/P&gt;&lt;P&gt;set input;&lt;/P&gt;&lt;P&gt;-all transformations blah blah blah---;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;After the above is run, the compare process is bound to follow However, before I the compare process executes I need the look up solution in the library and t&lt;STRONG&gt;he Logic for my requirement:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;1. Now,I am in need of a solution that should look for the&amp;nbsp; equivalent dataset named &lt;STRONG&gt;Past(&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libref.final_output_&lt;STRONG&gt;past&lt;/STRONG&gt;_&lt;STRONG&gt;&amp;amp;customer_id)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;in the same library. So,here the differentiating word is past as opposed to present and the identifier being customer_id should match.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;2. Look up solution should find the match, and if the match is found then execute the compare process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;3. So something like this should make sense i hope *if &lt;SPAN style="font-size: 13.3333330154419px;"&gt;libref.final_output_&lt;STRONG&gt;past&lt;/STRONG&gt;_&lt;STRONG&gt;&amp;amp;customer_id exists in the libref then do: execute compare process:end;else do skip compare process and just do load process;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd greatly appreciate this help as this would really mean a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Charlotte&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 18:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-Dataset-in-a-library-and-do-a-matching-look-up/m-p/201842#M305976</guid>
      <dc:creator>CharlotteCain</dc:creator>
      <dc:date>2015-08-18T18:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to 'find' a Dataset in a library and do a matching look up conditionally?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-Dataset-in-a-library-and-do-a-matching-look-up/m-p/201843#M305977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears that you are doing this for a specified customer id. If so something like this might be a workable start:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro DoCompare(id= );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %sysfunc(exist(libref.final_output_past_&amp;amp;id)) %then %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;lt;here would go the code for when the file exists&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %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;lt;whatever you do when it isn't found&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And call using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%DoCompare(id=&amp;amp;customer_id);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 19:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-Dataset-in-a-library-and-do-a-matching-look-up/m-p/201843#M305977</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-18T19:24:59Z</dc:date>
    </item>
  </channel>
</rss>

