<?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 can I identify all the variables with duplicate values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398140#M278363</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154079"&gt;@jjknknl&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a dataset with many variables, and I would like to flag all the variables that have any duplicated values. I first did&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=foo&amp;nbsp;out=tmp noprint; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I have a table i can work with called tmp, with one row per variable. &amp;nbsp;I would like to add a new column, call it "DUPLICATES", to tmp that is TRUE if the variable contains any duplicated values, and is FALSE, if it contains all unique values.&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;am having a very hard time figuring out what the best way to do this is. Can someone please help? &amp;nbsp;Also, there are many variables in the dataset so I would prefer a way that does not require me to know and type out the variable names individually.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about providing some example data, maybe with 5 variables or so with different combinations of numbers of duplicates and without and then show what the final&amp;nbsp;result would look like for that example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason I suggest the example desired output is it really depends on what you think you want and I'm pretty sure I do not know what that is. If you want something that shows var1=var2 in some way we need to know what it is. We also need to know if you need to distinguish between var1=var2 and var1=var3 separately or if a single variable can hold all of the values if any that equal var1. One approach could require as many as 10 additional variables to track the comparisons of 5 variables. It appears as a minimum that you may want one flag variable per variable but I'm not exactly sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also are all of your variables numeric, all character or is there a mix? And if you have mixed numeric and character is it a "duplicate" if one variable has numeric 1 and a character variable has character "1"?&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2017 15:23:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-09-22T15:23:17Z</dc:date>
    <item>
      <title>How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397950#M278357</link>
      <description>&lt;P&gt;I have a dataset with many variables, and I would like to flag all the variables that have any duplicated values. I first did&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc contents data=foo&amp;nbsp;out=tmp noprint; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I have a table i can work with called tmp, with one row per variable. &amp;nbsp;I would like to add a new column, call it "DUPLICATES", to tmp that is TRUE if the variable contains any duplicated values, and is FALSE, if it contains all unique values.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;am having a very hard time figuring out what the best way to do this is. Can someone please help? &amp;nbsp;Also, there are many variables in the dataset so I would prefer a way that does not require me to know and type out the variable names individually.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 22:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397950#M278357</guid>
      <dc:creator>jjknknl</dc:creator>
      <dc:date>2017-09-21T22:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397954#M278358</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154079"&gt;@jjknknl&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Proc Freq and Proc Univariate are two common procedures used for data profiling.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 22:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397954#M278358</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-21T22:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397963#M278359</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a table that is a transpose of the normal data table.&amp;nbsp; So a lot of the normal PROC's will not be of help unless you transpose back to obs as rows and variables as columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could run a DATA step.&amp;nbsp; Let's say you have a data set with a var called VARNAME, and a set of numeric values in vars X1-X20:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=I);
  set have;
  array x {*} x1-x20;
  call sortn(of x{*});

  duplicate='FALSE';
  do I=1 to 19 while (duplicate='FALSE');
    if x{I}=x{I+1} then duplicate='TRUE';
  end;

  set have;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a second SET statement in this data step.&amp;nbsp; That's because the CALL SORTN statement changes the order of the values in X1 through X20, which of course you don't want in the output data set.&amp;nbsp; So a second SET statement is executed after the value of duplicate is established, rereading the original X1-X20 values.&amp;nbsp; I.e. the 2 set statements read from HAVE in parallel, not as interleaved records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "while (duplicate='FALSE')" clause allows the DO loop iteration to stop as soon as duplicates are found.&amp;nbsp; Not need to continue once the first duplicate is encountered.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 23:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397963#M278359</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-21T23:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397965#M278360</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is only a partial answer-I will add to it if I have more time later. To get a list of duplicate values you can use the freq procedure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FREQ DATA=my_data NOPRINT;&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;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;TABLES Employee_ID / OUT=EmpFreq;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC PRINT DATA=EmpFreq;&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE count&amp;gt;1;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can use a WHERE= data set option wen creating the output dataset with counts:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FREQ DATA= my_data NOPRINT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; TABLES Employee_ID / OUT=EmpFreq2 (WHERE=(count&amp;gt;1));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC PRINT DATA=EmpFreq2;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;an easy way to get a list of variables in a dataset that lets you avoid typing them by hand is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC CONTENTS DATA=my_data SHORT;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this will give you just the variable names. &amp;nbsp;You can copy and paste them&amp;nbsp;back into your editor window to avoid typing the variables&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 23:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/397965#M278360</guid>
      <dc:creator>Tarek_Elnaccash</dc:creator>
      <dc:date>2017-09-21T23:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398131#M278361</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37472"&gt;@Tarek_Elnaccash&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154079"&gt;@jjknknl&lt;/a&gt;&amp;nbsp;is NOT looking for instances of a repeated employee id, which your program does effectively, but rather the presence of duplicate values among the H values for a given row.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154079"&gt;@jjknknl&lt;/a&gt;, am I correct?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398131#M278361</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-22T15:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398136#M278362</link>
      <description>&lt;P&gt;Is this&amp;nbsp;solution looking to see if values in one variable are duplicated in another variable? &amp;nbsp;If so, this is not what I want. &amp;nbsp;I only want to look within each variable in the dataset, to see if that variable has any duplicate values. &amp;nbsp;So in this example, I want to look within each variable in foo, and check whether there are duplicates within that variable, or if all the values within that variable are unique.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing PROC CONTENTS on foo&amp;nbsp;yields a table&amp;nbsp;(which has one row per variable in the foo dataset), call it tmp, that does not have a column with this information, so I want to add such a column to it, call it "DUPLICATES". &amp;nbsp;For each row in tmp (corresponding to a variable in foo) it would be TRUE if that variable listed in that row has any duplicates, and FALSE if it does not. &amp;nbsp;For example, if the first variable in the dataset foo is A, then the first row of the PROC CONTENTS table (call it tmp) is&amp;nbsp;for A, and if A in foo has any duplicates then&amp;nbsp;the value of DUPLICATES in the first row of tmp would be "TRUE".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks very much for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398136#M278362</guid>
      <dc:creator>jjknknl</dc:creator>
      <dc:date>2017-09-22T15:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398140#M278363</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154079"&gt;@jjknknl&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a dataset with many variables, and I would like to flag all the variables that have any duplicated values. I first did&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=foo&amp;nbsp;out=tmp noprint; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I have a table i can work with called tmp, with one row per variable. &amp;nbsp;I would like to add a new column, call it "DUPLICATES", to tmp that is TRUE if the variable contains any duplicated values, and is FALSE, if it contains all unique values.&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;am having a very hard time figuring out what the best way to do this is. Can someone please help? &amp;nbsp;Also, there are many variables in the dataset so I would prefer a way that does not require me to know and type out the variable names individually.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about providing some example data, maybe with 5 variables or so with different combinations of numbers of duplicates and without and then show what the final&amp;nbsp;result would look like for that example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason I suggest the example desired output is it really depends on what you think you want and I'm pretty sure I do not know what that is. If you want something that shows var1=var2 in some way we need to know what it is. We also need to know if you need to distinguish between var1=var2 and var1=var3 separately or if a single variable can hold all of the values if any that equal var1. One approach could require as many as 10 additional variables to track the comparisons of 5 variables. It appears as a minimum that you may want one flag variable per variable but I'm not exactly sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also are all of your variables numeric, all character or is there a mix? And if you have mixed numeric and character is it a "duplicate" if one variable has numeric 1 and a character variable has character "1"?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398140#M278363</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-22T15:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398154#M278364</link>
      <description>&lt;P&gt;Thanks very much for your help. &amp;nbsp;Please see my response to mkeintz. &amp;nbsp;Also, to give a concrete example, please consider the following dataset "foo"&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;e&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;When i do PROC CONTENTS on this, i get the following table, call it "tmp"&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Label&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;First variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Second variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;Third variable&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;Fourth variable&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;It actually has many more columns than just Name and Label but i've omitted them for the sake of clarity. &amp;nbsp;What I ultimately want is the following&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Label&lt;/TD&gt;&lt;TD&gt;DUPLICATES&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;First variable&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Second variable&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;Third variable&lt;/TD&gt;&lt;TD&gt;TRUE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;Fourth variable&lt;/TD&gt;&lt;TD&gt;TRUE&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Does that make it clear? &amp;nbsp;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398154#M278364</guid>
      <dc:creator>jjknknl</dc:creator>
      <dc:date>2017-09-22T15:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398203#M278365</link>
      <description>&lt;P&gt;I am looking to see if each variable has repeated values/records/rows/observations or not. &amp;nbsp;I'm NOT looking for duplicates across variables, only within variables. &amp;nbsp;Each variable can be considered completely independently of all others. For example,&amp;nbsp;a variable may contain ID numbers, and i want to see if any ID numbers are repeated in that variable (ignoring all other variables in the dataset). &amp;nbsp;I don't care what the repeated ID numbers, i just ultimately want a way to&amp;nbsp;output TRUE if the variable has any duplicates, and FALSE if it does not. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 18:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398203#M278365</guid>
      <dc:creator>jjknknl</dc:creator>
      <dc:date>2017-09-22T18:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398205#M278366</link>
      <description>&lt;P&gt;A,B,C, and D are the variable names in this dataset, and there are 5 values/rows/observations/records per variable. The variable C in this dataset has duplicates (the first and second values/rows/observations/records are both 1), and the variable D has duplicates (the first and fifth values/rows/observations/records are both "a"). That is why DUPLICATES=TRUE for them. The variable A has no duplicates, i.e., all values are unique, and the variable B has no duplicates either. &amp;nbsp;That is why DUPLICATES=FALSE for them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 18:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398205#M278366</guid>
      <dc:creator>jjknknl</dc:creator>
      <dc:date>2017-09-22T18:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I identify all the variables with duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398237#M278367</link>
      <description>&lt;P&gt;Please look at:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input A  B $ C D $;
datalines;
1 a 1 a 
2 b 1 b 
3 c 2 c 
4 d 3 d 
5 e 4 a 
;
run;
/* replace WORK and HAVE with the name of your actual dataset*/
proc sql noprint;
   select nobs into : rowcount
   from dictionary.tables where
   libname='WORK' and memname='HAVE'
   ;
run;
%put &amp;amp;rowcount;

/*put the libname.dataset in this procfreq code*/
proc freq data=have nlevels  ;
ods output Nlevels=Havelevels;
run;

data want;
   set HaveLevels (drop=NMissLevels NNonMissLevels);
 
   If Nlevels = &amp;amp;rowcount then Duplicates='FALSE';
   else Duplicates='TRUE';

run;&lt;/PRE&gt;
&lt;P&gt;I had to create a dataset have for the example. Use your dataset libname and dataset name in place of "have".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that in the Proc Sql part the library&amp;nbsp; name and data set are stored in uppercase so the values have to be upper or use functions to make them match.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 22:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-identify-all-the-variables-with-duplicate-values/m-p/398237#M278367</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-22T22:37:06Z</dc:date>
    </item>
  </channel>
</rss>

