<?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: apply function and creating matrix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697679#M213255</link>
    <description>&lt;P&gt;I do not understand what all to words are getting around.&lt;/P&gt;
&lt;P&gt;It would be much easier, as asked,&lt;FONT color="#800080"&gt; &lt;STRONG&gt;what does the result for your example data look like?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Just because you started a method does not mean that is the way to actually accomplish this.&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;But we need to know what you expect for output.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;And you have now added things that were not in the initial question such as: "unique for another variable".&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;So, how do you expect to &lt;STRONG&gt;display &lt;/STRONG&gt;the unique vs non-unique? What are the expected variable names in the output? Actual values for every row for each variable in your output? Answer these questions using the example data set you provided. &lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Nov 2020 17:58:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-09T17:58:43Z</dc:date>
    <item>
      <title>apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697602#M213219</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I create this function:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro unicite(input, output, x1, x2);
PROC SQL INOBS=1;
    CREATE TABLE output AS 
           SELECT 
	 	   (COUNT(DISTINCT(&amp;amp;x1))) AS &amp;amp;x1_&amp;amp;x2
      	   FROM input
           GROUP BY &amp;amp;x2
           ORDER BY &amp;amp;x1_&amp;amp;x2 DESC;
QUIT;
%mend;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create matrix for this list:&lt;/P&gt;&lt;PRE&gt;%let list= col1 col2 col3 col4 col5;&lt;/PRE&gt;&lt;P&gt;my final result by applying function unicite must be like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;col1_col1&lt;/TD&gt;&lt;TD&gt;col1_col2&lt;/TD&gt;&lt;TD&gt;col1_col3&lt;/TD&gt;&lt;TD&gt;col1_col4&lt;/TD&gt;&lt;TD&gt;col1_col5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col2_col1&lt;/TD&gt;&lt;TD&gt;col2_col2&lt;/TD&gt;&lt;TD&gt;col2_col3&lt;/TD&gt;&lt;TD&gt;col2_col4&lt;/TD&gt;&lt;TD&gt;col2_col5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col3_col1&lt;/TD&gt;&lt;TD&gt;col3_col2&lt;/TD&gt;&lt;TD&gt;col3_col3&lt;/TD&gt;&lt;TD&gt;col3_col4&lt;/TD&gt;&lt;TD&gt;col3_col5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col4_col1&lt;/TD&gt;&lt;TD&gt;col4_col2&lt;/TD&gt;&lt;TD&gt;col4_col3&lt;/TD&gt;&lt;TD&gt;col4_col4&lt;/TD&gt;&lt;TD&gt;col4_col5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col5_col1&lt;/TD&gt;&lt;TD&gt;col5_col2&lt;/TD&gt;&lt;TD&gt;col5_col3&lt;/TD&gt;&lt;TD&gt;col5_col4&lt;/TD&gt;&lt;TD&gt;col5_col5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 09 Nov 2020 13:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697602#M213219</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T13:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697645#M213233</link>
      <description>&lt;P&gt;Provide some actual example data in the form of a data step and what the actual result of the output should look like for that data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea what a "col1_col2" would be and in general SQL is likely not the place do anything related to a "matrix".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 15:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697645#M213233</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-09T15:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697649#M213236</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* this  is my data set */&lt;BR /&gt;data have;
input col1 $ col2 col3 $ col4 col5;
cards;

Jac 10 s 1 0

Joe 31 s 1 0

Joe 22 l 2 0

Roe 33 l 1 1

Rex 44 s 1 0

Tim 24 s 1 0

Joe 31 s 2 0

Joe 22 l 1 1

Roe 33 l 2 1

Rex 44 s 1 1

Tim 24 s 1 1

;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;until now&amp;nbsp;I have achieved this result bu it's not exactly what I want&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result is just for &lt;STRONG&gt;col1&lt;/STRONG&gt;&amp;nbsp;I want for all columns (col1 col2 ...) you can see in the function&amp;nbsp;%unicite(have,want,&lt;STRONG&gt;col1&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro unicite(entree,sortie,col);&lt;BR /&gt;%let list=col1 &lt;BR /&gt;col2 &lt;BR /&gt;col3&lt;BR /&gt;col4 &lt;BR /&gt;col5 &lt;BR /&gt;;&lt;BR /&gt;data TABLE_INSPECTION;&lt;BR /&gt;set _NULL_;&lt;BR /&gt;run;&lt;BR /&gt;%do index = 1 %to %sysfunc(countw(&amp;amp;list,%str( )));&lt;BR /&gt;%let I =%scan(&amp;amp;list,&amp;amp;index,%str( ));&lt;BR /&gt;PROC SQL OUTOBS=1 ;&lt;BR /&gt;CREATE TABLE &amp;amp;sortie AS &lt;BR /&gt;SELECT &lt;BR /&gt;(COUNT(DISTINCT(&amp;amp;I))) AS &amp;amp;I&lt;BR /&gt;FROM &amp;amp;entree &lt;BR /&gt;GROUP BY &amp;amp;col&lt;BR /&gt;ORDER BY &amp;amp;I DESC;&lt;BR /&gt;QUIT;&lt;BR /&gt;data TABLE_INSPECTION;&lt;BR /&gt;set TABLE_INSPECTION &amp;amp;sortie;&lt;BR /&gt;run;&lt;BR /&gt;proc delete data=&amp;amp;sortie;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%unicite(have,want,col1);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 15:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697649#M213236</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T15:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697652#M213237</link>
      <description>&lt;P&gt;You need to show what the result for that data should be.&lt;/P&gt;
&lt;P&gt;Showing code that does not do as required is&lt;/P&gt;
&lt;P&gt;And does the result need to be data set that will processed further or a Report that people with read?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, it is poor form to include blank lines in Cards data.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 16:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697652#M213237</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-09T16:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697662#M213244</link>
      <description>&lt;P&gt;the result should be data not report&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 16:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697662#M213244</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T16:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697665#M213246</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;the result should be data not report&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Again, what does the result look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a serious consideration involving variable type because SAS will only allow a variable to be of one type and the way you are mixing "columns" needs a very clear example of what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, what will be done with this data set next?&lt;/P&gt;
&lt;P&gt;Anything someone calls a "matrix" usually properly belongs in Proc IML and SQL is right out.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 16:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697665#M213246</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-09T16:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697675#M213251</link>
      <description>&lt;P&gt;It is within the framework of my end of studies project I want to check in a table which contains 5 variables, if each variable is unique for another variable.&lt;BR /&gt;I want to do this in an iterative fashion every time I set a variable in the group and count the values of the other variables one by one&lt;BR /&gt;at the end I will have cases when the value is 1 so it is unique and cases&amp;gt; 1 therefore not unique&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 17:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697675#M213251</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T17:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697679#M213255</link>
      <description>&lt;P&gt;I do not understand what all to words are getting around.&lt;/P&gt;
&lt;P&gt;It would be much easier, as asked,&lt;FONT color="#800080"&gt; &lt;STRONG&gt;what does the result for your example data look like?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Just because you started a method does not mean that is the way to actually accomplish this.&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;But we need to know what you expect for output.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;And you have now added things that were not in the initial question such as: "unique for another variable".&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;So, how do you expect to &lt;STRONG&gt;display &lt;/STRONG&gt;the unique vs non-unique? What are the expected variable names in the output? Actual values for every row for each variable in your output? Answer these questions using the example data set you provided. &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 17:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697679#M213255</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-09T17:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697683#M213258</link>
      <description>&lt;P&gt;My result should look like this table&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;col1&lt;/TD&gt;&lt;TD&gt;col2&lt;/TD&gt;&lt;TD&gt;col3&lt;/TD&gt;&lt;TD&gt;col4&lt;/TD&gt;&lt;TD&gt;col5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;col5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;for exemple between col1 col1 we have 1 because we check for the same variable&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC SQL INOBS=1;
    CREATE TABLE output AS 
           SELECT 
	 	   (COUNT(DISTINCT(col1))) AS col1_col1
      	   FROM input
           GROUP BY col1
           ORDER BY col1_col1 DESC;
QUIT;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 18:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697683#M213258</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T18:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697690#M213265</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;My result should look like this table&lt;/P&gt;
&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;col1&lt;/TD&gt;
&lt;TD&gt;col2&lt;/TD&gt;
&lt;TD&gt;col3&lt;/TD&gt;
&lt;TD&gt;col4&lt;/TD&gt;
&lt;TD&gt;col5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;col1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;col2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;col3&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;col4&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;col5&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;for exemple between col1 col1 we have 1 because we check for the same variable&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC SQL INOBS=1;
    CREATE TABLE output AS 
           SELECT 
	 	   (COUNT(DISTINCT(col1))) AS col1_col1
      	   FROM input
           GROUP BY col1
           ORDER BY col1_col1 DESC;
QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since that proc sql is restricted on one record I don't see anyway that you would ever get more than 1. So why the restriction INOBS=1????&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your col1 variable has 5 unique values, with counts of 1, 2 and 4 when crossed with itself I don't really understand your output.&lt;/P&gt;
&lt;P&gt;So step by step demonstrate, not with code but with words and by showing the explicit values used to show some of those counts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 18:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697690#M213265</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-09T18:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697697#M213270</link>
      <description>&lt;P&gt;&lt;SPAN&gt;no I will not always have 1 as a result try this code and you will see. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input col1 $ col2 col3 $ col4 col5;
cards;

Jac 10 s 1 0

Joe 31 s 1 0

Joe 22 l 2 0

Roe 33 l 1 1

Rex 44 s 1 0

Tim 24 s 1 0

Joe 31 s 2 0

Joe 22 l 1 1

Roe 33 l 2 1

Rex 44 s 1 1

Tim 24 s 1 1

;
run;
PROC SQL outobs=1;
    CREATE TABLE output AS 
           SELECT 
	 	   (COUNT(DISTINCT(col3))) AS col1_col1
      	   FROM have
           GROUP BY col1
           ORDER BY col1_col1 DESC;
QUIT;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the reason why I do outobs = 1 because I have ranked the observations in descending order and I am only interested in the highest value if it's equal 1 then the variable is unique&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 19:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697697#M213270</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T19:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697698#M213271</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;no I will not always have 1 as a result try this code and you will see. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input col1 $ col2 col3 $ col4 col5;
cards;

Jac 10 s 1 0

Joe 31 s 1 0

Joe 22 l 2 0

Roe 33 l 1 1

Rex 44 s 1 0

Tim 24 s 1 0

Joe 31 s 2 0

Joe 22 l 1 1

Roe 33 l 2 1

Rex 44 s 1 1

Tim 24 s 1 1

;
run;
PROC SQL outobs=1;
    CREATE TABLE output AS 
           SELECT 
	 	   (COUNT(DISTINCT(col3))) AS col1_col1
      	   FROM have
           GROUP BY col1
           ORDER BY col1_col1 DESC;
QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the reason why I do outobs = 1 because I have ranked the observations in descending order and I am only interested in the highest value if it's equal 1 then the variable is unique&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You changed the SQL code. Previously you had INOBS=1. So without any further actual worked example of the process I am done here.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 19:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697698#M213271</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-09T19:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: apply function and creating matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697705#M213274</link>
      <description>&lt;P&gt;it's mistake sorry&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 20:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/apply-function-and-creating-matrix/m-p/697705#M213274</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-11-09T20:04:32Z</dc:date>
    </item>
  </channel>
</rss>

