<?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: Not Sure What Proc To Use in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/243011#M55885</link>
    <description>&lt;P&gt;There are indeed many different ways to achieve this. I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;that it's nice to see all combinations. Here is an alternative to the "&lt;SPAN&gt;table binary1*binary2*binary3*binary4*binary5" approach with PROC FREQ. (Sometimes I have encountered memory shortage issues when applying such a 5- or higher-dimensional cross-table request to a large dataset.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; /* just to create dummy data */
array var a b c d e;
do j=1 to 100;
  do i=1 to 5;
    var[i]=(ranuni(314159)&amp;lt;0.5);
  end;
  output;
end;
drop i j;
run;

data combi;
set have;
length comb $5;
comb=cats(of a--e); /* creates the combinations like '01101' */
run;

proc freq data=combi;
tables comb;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Or you could use PROC SQL&amp;nbsp;without creating a new dataset (like COMBI above):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select a, b, c, d, e, count(*) as cnt
from have
group by a, b, c, d, e;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jan 2016 18:40:51 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-01-12T18:40:51Z</dc:date>
    <item>
      <title>Not Sure What Proc To Use</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/242968#M55880</link>
      <description>&lt;P&gt;Hello all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm rather rusty at SAS and was hoping for a bit of help. I have 5 binary variables and want to know how many observations reported "yes" for all 5 of them. Is there a way to do this? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 17:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/242968#M55880</guid>
      <dc:creator>chelsealutz</dc:creator>
      <dc:date>2016-01-12T17:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Not Sure What Proc To Use</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/242969#M55881</link>
      <description>Proc Freq is a good start.&lt;BR /&gt;&lt;BR /&gt;proc freq data=your_dataset_name;&lt;BR /&gt;table binary1*binary2*binary3*binary4*binary5/out=summary list;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=summary;&lt;BR /&gt;by descending binary1 descending binary2 descending binary3 descending binary4 descending binary5;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print data=summary;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;If you want to limit the results to only 1's you can use a WHERE to filter it out, though it's nice to see all the combinations.&lt;BR /&gt;&lt;BR /&gt;WHERE sum(binary1, binary2, .. , binary5) = 5;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jan 2016 17:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/242969#M55881</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-12T17:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Not Sure What Proc To Use</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/242972#M55882</link>
      <description>&lt;P&gt;Well, if you have something like:&lt;/P&gt;
&lt;PRE&gt;data have;
  var1=1; var2=0; var3=1; var4=1; output;
  var1=1; var2=1; var3=1; var4=1; output;
run;

data want;
  set have end=last;
  retain result 0;
  array var{4};
  if sum(of var{*})=4 then result=sum(result,1);
  if last then output;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2016 17:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/242972#M55882</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-12T17:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Not Sure What Proc To Use</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/243011#M55885</link>
      <description>&lt;P&gt;There are indeed many different ways to achieve this. I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;that it's nice to see all combinations. Here is an alternative to the "&lt;SPAN&gt;table binary1*binary2*binary3*binary4*binary5" approach with PROC FREQ. (Sometimes I have encountered memory shortage issues when applying such a 5- or higher-dimensional cross-table request to a large dataset.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; /* just to create dummy data */
array var a b c d e;
do j=1 to 100;
  do i=1 to 5;
    var[i]=(ranuni(314159)&amp;lt;0.5);
  end;
  output;
end;
drop i j;
run;

data combi;
set have;
length comb $5;
comb=cats(of a--e); /* creates the combinations like '01101' */
run;

proc freq data=combi;
tables comb;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Or you could use PROC SQL&amp;nbsp;without creating a new dataset (like COMBI above):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select a, b, c, d, e, count(*) as cnt
from have
group by a, b, c, d, e;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 18:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/243011#M55885</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-12T18:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Not Sure What Proc To Use</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/243018#M55886</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;@RW9 @FreelanceReinhard&amp;nbsp;Thank you all for your replies!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 18:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Not-Sure-What-Proc-To-Use/m-p/243018#M55886</guid>
      <dc:creator>chelsealutz</dc:creator>
      <dc:date>2016-01-12T18:50:47Z</dc:date>
    </item>
  </channel>
</rss>

