<?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 count of unique values across many columns by class in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534365#M6308</link>
    <description>&lt;P&gt;If I have the following data&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA raw;
	INPUT group $ var1 $ var2 $;
	CARDS;
	A Y Y
	A Y N
	A N N
	A Y Y
	A Y Y
	B N N
	B N N
	B N N
	B Y N
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want my result to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Group value var1 var2
  A     Y    4    3
  A     N    1    2
  B     Y    1    0
  B     N    3    4&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assume that there are many more variable columns in the actual data set. How do I do this without just using proc tabulate on each variable and then manually joining the result tables together?&lt;/P&gt;</description>
    <pubDate>Mon, 11 Feb 2019 05:01:45 GMT</pubDate>
    <dc:creator>CJ_Jackson</dc:creator>
    <dc:date>2019-02-11T05:01:45Z</dc:date>
    <item>
      <title>count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534365#M6308</link>
      <description>&lt;P&gt;If I have the following data&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA raw;
	INPUT group $ var1 $ var2 $;
	CARDS;
	A Y Y
	A Y N
	A N N
	A Y Y
	A Y Y
	B N N
	B N N
	B N N
	B Y N
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want my result to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Group value var1 var2
  A     Y    4    3
  A     N    1    2
  B     Y    1    0
  B     N    3    4&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assume that there are many more variable columns in the actual data set. How do I do this without just using proc tabulate on each variable and then manually joining the result tables together?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534365#M6308</guid>
      <dc:creator>CJ_Jackson</dc:creator>
      <dc:date>2019-02-11T05:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534367#M6309</link>
      <description>&lt;P&gt;many columns is "how many"? (can you give us a rough estimate?)&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534367#M6309</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T05:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534368#M6310</link>
      <description>&lt;P&gt;about 20 or so. Essentially I want to avoid manually doing this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534368#M6310</guid>
      <dc:creator>CJ_Jackson</dc:creator>
      <dc:date>2019-02-11T05:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534369#M6311</link>
      <description>&lt;P&gt;I totally agree with you. Just thinking of how best that can be done&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534369#M6311</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T05:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534372#M6312</link>
      <description>&lt;P&gt;see if this helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA raw;
	INPUT group $ var1 $ var2 $;
	CARDS;
	A Y Y
	A Y N
	A N N
	A Y Y
	A Y Y
	B N N
	B N N
	B N N
	B Y N
	;
run;
data t;
set raw;
array t(*) var:;
do i= 1 to dim(t);
vn=vname(t(i));
val=t(i);
output;
end;
keep group vn val;
run;

proc sql;
create table w2 as
select group, vn,val,count(val) as c
from t
group by group, vn,val
order by group ,val;
quit;

proc transpose data=w2 out=want(drop=_name_);
by group val;
var c;
id vn ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534372#M6312</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T05:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534373#M6313</link>
      <description>&lt;P&gt;Yeah, this works. Thanks. So basically I have to change the original data set from wide to long. I wonder if proc transpose could be used to achieve that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534373#M6313</guid>
      <dc:creator>CJ_Jackson</dc:creator>
      <dc:date>2019-02-11T05:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534374#M6314</link>
      <description>First normalize the data.&lt;BR /&gt;&lt;BR /&gt;Data want:&lt;BR /&gt;set have;&lt;BR /&gt;array varieties [20] /* add var names if not  var1-var20 */;&lt;BR /&gt;Do k=1 to 20;&lt;BR /&gt;  value = var[k];&lt;BR /&gt;  variable = vname(var[k]);&lt;BR /&gt;  output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Now Proc Tabulate can easily generate a combined report.&lt;BR /&gt;&lt;BR /&gt;proc tabulate data=want;&lt;BR /&gt;class variable value group;&lt;BR /&gt;tables group*value, variable;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Feb 2019 05:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534374#M6314</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-11T05:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: count of unique values across many columns by class</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534375#M6315</link>
      <description>Array  var not varieties... hate these handhelds!!!</description>
      <pubDate>Mon, 11 Feb 2019 05:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-of-unique-values-across-many-columns-by-class/m-p/534375#M6315</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-11T05:57:19Z</dc:date>
    </item>
  </channel>
</rss>

