<?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: Summary table of freq for multiple binary vars in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621992#M182924</link>
    <description>&lt;P&gt;Some explicit example might help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is a report that people will read and not an odd data set structure and your binary variables are coded 1/0 then the summary statistic SUM will get you the number of 1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc tabulate data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var z1-z10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; table z1-z10,&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; sum='Count of 1'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;may work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW: The Mean statistic will give you the percent of 1's in the data in decimal form for 1/0 coded values.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Feb 2020 17:04:27 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-02-03T17:04:27Z</dc:date>
    <item>
      <title>Summary table of freq for multiple binary vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621609#M182746</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Let's sat that I have a row data set that contain for each ID ,multiple categorical binary variables: Z1,Z2,Z3..........Z10.&lt;/P&gt;
&lt;P&gt;I want to create a summary table with two columns:&lt;/P&gt;
&lt;P&gt;Columns 1 will be called "Field" and will get value of the binary var name&lt;/P&gt;
&lt;P&gt;Columns 1 will be called "Count" and will get value of number of rows with value1&lt;/P&gt;
&lt;P&gt;The wanted data set will look like that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="E1.PNG" style="width: 136px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35794i0D12DCC6BE93071D/image-size/large?v=v2&amp;amp;px=999" role="button" title="E1.PNG" alt="E1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What is the best way to do it please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 09:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621609#M182746</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-01T09:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Summary table of freq for multiple binary vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621618#M182753</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an attempt to do this.&lt;/P&gt;
&lt;P&gt;Let me know if that does answer your question.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID Z1-Z10;
	datalines;
1 1 0 1 0 1 0 1 0 1 0
2 0 0 0 0 0 0 0 0 0 0
3 1 1 1 1 1 1 1 1 1 1
4 1 1 1 1 1 0 0 0 0 0
;
run;

data have_sum;
	set have end=_end;
	array z(10);
	array count(10) _temporary_;
	do i=1 to dim(z);
		count(i)+ z(i);
		z(i) = count(i);
	end;
	drop i id;
	if _end then output;
run;

proc transpose data=have_sum out=want (rename= (col1=Count)) name = Field;
	var Z1-Z10;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Feb 2020 10:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621618#M182753</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-01T10:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Summary table of freq for multiple binary vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621992#M182924</link>
      <description>&lt;P&gt;Some explicit example might help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is a report that people will read and not an odd data set structure and your binary variables are coded 1/0 then the summary statistic SUM will get you the number of 1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc tabulate data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var z1-z10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; table z1-z10,&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; sum='Count of 1'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;may work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW: The Mean statistic will give you the percent of 1's in the data in decimal form for 1/0 coded values.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 17:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-table-of-freq-for-multiple-binary-vars/m-p/621992#M182924</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-03T17:04:27Z</dc:date>
    </item>
  </channel>
</rss>

