<?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: Compare Datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754019#M237713</link>
    <description>Find common varables in a library for all data sets</description>
    <pubDate>Wed, 14 Jul 2021 09:50:02 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2021-07-14T09:50:02Z</dc:date>
    <item>
      <title>Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/753999#M237703</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds1 ;
set sashelp.class;
run;

data ds1;
set sashelp.class;
run;

data ds3;
set sashelp.class;
run;

   
proc sql ;
select * from dictionary.columns where libname='WORK' and memname ='DATA'
			/*ADD THE VARIABLE LIST HERE*/
			order by memname, name;
	quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jul 2021 06:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/753999#M237703</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-07-14T06:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754000#M237704</link>
      <description>&lt;P&gt;What is your question?&lt;/P&gt;
&lt;P&gt;The SQL will successfully create a listing of the entries in the dictionary table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction: if you had used MEMTYPE instead of MEMNAME. Running the SELECT with the restriction to library WORK only would have let you see which column contains the value "DATA".&lt;/P&gt;
&lt;P&gt;But that needs using the tool between your ears.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 10:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754000#M237704</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-14T10:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754017#M237711</link>
      <description>&lt;P&gt;I am not 100% sure, but maybe sas create proc compare to compare datasets.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 09:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754017#M237711</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-14T09:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754019#M237713</link>
      <description>Find common varables in a library for all data sets</description>
      <pubDate>Wed, 14 Jul 2021 09:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754019#M237713</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-07-14T09:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754020#M237714</link>
      <description>Find common varables in a library for all</description>
      <pubDate>Wed, 14 Jul 2021 09:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754020#M237714</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-07-14T09:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754021#M237715</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You ask for a memname called DATA. To get your created data sets, try changing the select statement to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from dictionary.columns where libname='WORK' and memname EQT 'DS'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This returns DS1 and DS3. You don't get a DS2, because you create DS1 twice.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 09:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754021#M237715</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2021-07-14T09:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754022#M237716</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a list of all variables that exist in ALL the selected tables, use this select:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
	select distinct name, count(*) as antal 
		from dictionary.columns 
		where libname='WORK' and memname EQT 'DS'
		group by name
		having antal = (
			select count(distinct memname)
			from dictionary.columns 
			where libname='WORK' and memname EQT 'DS'
		);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 10:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754022#M237716</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2021-07-14T10:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754029#M237719</link>
      <description>&lt;P&gt;Please show what you expect as output.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 10:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754029#M237719</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-14T10:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754031#M237721</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Find common varables in a library for all data sets&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First, get a count of the datasets, and then only the names that have that count:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds1;
set sashelp.class;
run;

data ds2;
set sashelp.class;
run;

data ds3;
set sashelp.class (drop=sex);
run;

proc sql noprint;
select count(*) into :dscount from dictionary.tables where libname = "WORK";
quit;
proc sql;
select name from dictionary.columns where libname = "WORK"
group by name
having count(name) = &amp;amp;dscount.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Column Name
Age
Height
Name
Weight
&lt;/PRE&gt;
&lt;P&gt;Note that sex is absent as I removed it from ds3.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 10:46:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754031#M237721</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-14T10:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754092#M237746</link>
      <description>&lt;P&gt;I didn't get why you use ds instead data ,we have memtypes namely DATA,VIEW ,CATALOG&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 14:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754092#M237746</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-07-14T14:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754126#M237759</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I didn't get why you use ds instead data ,we have memtypes namely DATA,VIEW ,CATALOG&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Read again, and take your time to get it right. The comparison is not with MEMTYPE.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754126#M237759</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-14T16:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compare Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754135#M237762</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Find common varables in a library for all&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's one of my generic approaches to examining variables in multiple data sets of a library.&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.vcolumn;
   where libname='WORK' and memtype='DATA' ;
   class name type memname;
   table name*type,
         memname*n=' '
         /misstext=' '
   ;
run;&lt;/PRE&gt;
&lt;P&gt;There is a 1 in the row/column intersection of variable name, type and memname (data set). I include the data type as you can see very quickly if any of the variables are of different types which is a common cause of problems when using "all the data sets in a library". You could even through in the Length into the table if you suspect that lengths change and could cause problems but that can lead to a very big table quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tabulate does have limits on table size so if you have 1000's of variables and 100's of data sets this may not complete.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 17:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-Datasets/m-p/754135#M237762</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-14T17:20:52Z</dc:date>
    </item>
  </channel>
</rss>

