<?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: Comparing Dataset dynamically between two library in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884083#M43285</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;Why not having a macro that takes the name of a dataset as a parameter, does all the magic that is needed before you are ready to issue the proc compare ... and finally commits the proc compare?&lt;/P&gt;
&lt;P&gt;Querying the constitutents of the two libraries and looping over them would be a second step. But all this requires, of course and as Reeza has already mentioned, that you have working code readily available. Is that the case?&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;P&gt;fja&lt;/P&gt;</description>
    <pubDate>Sun, 09 Jul 2023 12:36:20 GMT</pubDate>
    <dc:creator>fja</dc:creator>
    <dc:date>2023-07-09T12:36:20Z</dc:date>
    <item>
      <title>Comparing Dataset dynamically between two library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/883961#M43282</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope you are all doing good&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to compare the datasets. I am having 5 datasets, Dataset names may vary depend upon the project. In two library the datasets are saved. I need to compare the dataset between those two library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Temp library, I am having 7 files( File count won't change between library)&lt;/P&gt;
&lt;P&gt;CT_Sales&lt;BR /&gt;Payment_1&lt;BR /&gt;Payment_2&lt;BR /&gt;Payment_3&lt;BR /&gt;758_Transaction&lt;BR /&gt;CT758_2_Store&lt;BR /&gt;Product&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Temp1 Library, I am 7 files&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CT_Sales&lt;BR /&gt;Payment_1&lt;BR /&gt;Payment_2&lt;BR /&gt;Payment_3&lt;BR /&gt;758_Transaction&lt;BR /&gt;CT758_2_Store&lt;BR /&gt;Product&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we can compare these files easily by using PROC COMPARE. But, i want to do it using Macro(Dynamically) so that when the file name changes i don't need to update in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before comparing i need to do some changes in the dataset.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&amp;nbsp;Some time we will have multiple dataset which has different observation but same variable name. So, If i am having multiple dataset means i need to append those dataset and create a new dataset&lt;/LI&gt;
&lt;LI&gt;In my dataset, the original name is(Sales,Payment,Transaction,Store,Product) But I am having some prefix to it and it wont be the same for all dataset. So i need to remove those before comparing. I tried Compress function but, I am not able to achieve the expected result&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Once We modify our dataset as mentioned above then I need to compare it dynamically using macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know it's a lot to ask for. But, I am learning so it would be helpful for my learning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 14:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/883961#M43282</guid>
      <dc:creator>_el_doredo</dc:creator>
      <dc:date>2023-07-07T14:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Dataset dynamically between two library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884014#M43283</link>
      <description>Before you make a macro, the general rule of thumb is working code. Do you currently have working code?&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Jul 2023 20:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884014#M43283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-07-07T20:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Dataset dynamically between two library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884083#M43285</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;Why not having a macro that takes the name of a dataset as a parameter, does all the magic that is needed before you are ready to issue the proc compare ... and finally commits the proc compare?&lt;/P&gt;
&lt;P&gt;Querying the constitutents of the two libraries and looping over them would be a second step. But all this requires, of course and as Reeza has already mentioned, that you have working code readily available. Is that the case?&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;P&gt;fja&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 12:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884083#M43285</guid>
      <dc:creator>fja</dc:creator>
      <dc:date>2023-07-09T12:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Dataset dynamically between two library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884108#M43286</link>
      <description>&lt;P&gt;So you want something that can make some of the decisions for you?&amp;nbsp; &amp;nbsp;You mentioned two of the those areas where you will need to make decisions,&amp;nbsp; which datasets can be combined and which variables should be renamed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general that means you will need to generate code (what you called dynamic code).&amp;nbsp; A macro might be one way to make the code dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But first you will need to figure out what code you need to generate.&amp;nbsp; And how to gather the information you will need to decide how to generate it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one method you could use to compare datasets to see if they contain the same set of variables.&amp;nbsp; Basically use PROC TRANSPOSE to create one observation per dataset with the variables to store all of the variable names.&amp;nbsp; THen you can use BY group processing to create groups of datasets with the same set of variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table varnames as
  select libname,memname,upcase(name) as uname 
  from dictionary.columns
  where libname='WORK'
  order by libname,memname,uname
;
quit;

proc transpose data=varnames out=memnames(drop=_name_) prefix=var ;
  by libname memname;
  var uname;
run;

proc sort data=memnames ;
  by var: ;
run;

data memnames;
   set memnames ;
   by var: var1;
   group + first.var1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an example result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1688917853265.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85680iD9205AC983ADA5D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1688917853265.png" alt="Tom_0-1688917853265.png" /&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: You mentioned the COMPRESS() function.&amp;nbsp; That will not be of much value here as that is just used to remove characters from strings.&amp;nbsp; To remove prefixes you need to use something like SUBSTR() or perhaps TRANWRD() or TRANSTRN() function.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 15:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884108#M43286</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-09T15:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Dataset dynamically between two library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884109#M43287</link>
      <description>&lt;P&gt;Thank you all for replying. I am on some other priority work. Once I am done with those I will respond to this.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;thanks a lot&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 15:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Comparing-Dataset-dynamically-between-two-library/m-p/884109#M43287</guid>
      <dc:creator>_el_doredo</dc:creator>
      <dc:date>2023-07-09T15:55:10Z</dc:date>
    </item>
  </channel>
</rss>

