<?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: With proc freq can you only print the counts for a certain value of a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/With-proc-freq-can-you-only-print-the-counts-for-a-certain-value/m-p/628081#M77516</link>
    <description>&lt;P&gt;One basic approach to count a specific value for a variable with Proc Freq;&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.class;
   where sex='F';
   tables sex;
run;&lt;/PRE&gt;
&lt;P&gt;Which would require 30 calls to proc freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are not many potential values involved for any of the variables (less than 10 values)&amp;nbsp;I would likely just dump them all into a single proc freq call an look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data need;
   set have;
   array v &amp;lt;list of your thirty variables&amp;gt;;
   do i= 1 to dim(v);
      variable = vname(v[i]);
      if v[i]=0 then output;
   end;
   keep variable;
run;

proc freq data=need;
   tables variable;
run;
  &lt;/PRE&gt;
&lt;P&gt;The count of variable is how many times it appeared as a 0 in the source data set. Note: if you have a mix of character and numeric variables this won't work as an array can only have variables of one type. So if you actually have some character "0" you would split the variables between two differently named arrays and the character comparison would be for "0" instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2020 00:22:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-02-28T00:22:15Z</dc:date>
    <item>
      <title>With proc freq can you only print the counts for a certain value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/With-proc-freq-can-you-only-print-the-counts-for-a-certain-value/m-p/628076#M77515</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With proc freq (or another proc), is there a way to only print the counts for a certain value of a variable? I have 30+ variables and for each of those variables, I want to know how many observations in my sample had a value of 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 23:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/With-proc-freq-can-you-only-print-the-counts-for-a-certain-value/m-p/628076#M77515</guid>
      <dc:creator>laura_2</dc:creator>
      <dc:date>2020-02-27T23:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: With proc freq can you only print the counts for a certain value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/With-proc-freq-can-you-only-print-the-counts-for-a-certain-value/m-p/628081#M77516</link>
      <description>&lt;P&gt;One basic approach to count a specific value for a variable with Proc Freq;&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.class;
   where sex='F';
   tables sex;
run;&lt;/PRE&gt;
&lt;P&gt;Which would require 30 calls to proc freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are not many potential values involved for any of the variables (less than 10 values)&amp;nbsp;I would likely just dump them all into a single proc freq call an look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data need;
   set have;
   array v &amp;lt;list of your thirty variables&amp;gt;;
   do i= 1 to dim(v);
      variable = vname(v[i]);
      if v[i]=0 then output;
   end;
   keep variable;
run;

proc freq data=need;
   tables variable;
run;
  &lt;/PRE&gt;
&lt;P&gt;The count of variable is how many times it appeared as a 0 in the source data set. Note: if you have a mix of character and numeric variables this won't work as an array can only have variables of one type. So if you actually have some character "0" you would split the variables between two differently named arrays and the character comparison would be for "0" instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 00:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/With-proc-freq-can-you-only-print-the-counts-for-a-certain-value/m-p/628081#M77516</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-28T00:22:15Z</dc:date>
    </item>
  </channel>
</rss>

