<?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: How to count the number of variables with values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682679#M206659</link>
    <description>&lt;P&gt;If the values are character, you can use the CMISS() Function to count the missings and then the number of non-missing is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;count = 5 - cmiss(of diagnosis1-diagnosis5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Sep 2020 15:51:59 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-09T15:51:59Z</dc:date>
    <item>
      <title>How to count the number of variables with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682669#M206653</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I would like to ask for assistance on how to &amp;nbsp;write the SAS code to count number of variables with values.&lt;/P&gt;
&lt;P&gt;I have the following variables in my table&amp;nbsp;:&amp;nbsp;Diagnosis1,Diagnosis2, Diagnosis3, Diagnosis4, Diagnosis5&lt;/P&gt;
&lt;P&gt;And I would like to count the number of variables only if they have a value.&lt;/P&gt;
&lt;P&gt;For example, if I only have values for Diagnosis1 , Diagnosis2 and Diagnosis3 , and&amp;nbsp;there are NO&amp;nbsp;values for Diagnosis4 and Diagnosis5&amp;nbsp; , my diagnosis count will be&amp;nbsp; = 3 .&lt;/P&gt;
&lt;P&gt;Greatly appreciate any assistance.&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 15:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682669#M206653</guid>
      <dc:creator>lmtamina</dc:creator>
      <dc:date>2020-09-09T15:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of variables with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682670#M206654</link>
      <description>&lt;P&gt;In a SAS data step, use the N() function, something like this will work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
    set one; 
    count=n(of diagnosis1-diagnosis5);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 15:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682670#M206654</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-09T15:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of variables with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682671#M206655</link>
      <description>&lt;P&gt;Are your variables numeric or character?&lt;/P&gt;
&lt;P&gt;If the values are numeric you can use the N function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;diagnosis_count = n (diagnosis1,diagnosis2,diagnosis3,diagnosis4,diagnosis5);&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 15:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682671#M206655</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-09T15:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of variables with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682679#M206659</link>
      <description>&lt;P&gt;If the values are character, you can use the CMISS() Function to count the missings and then the number of non-missing is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;count = 5 - cmiss(of diagnosis1-diagnosis5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 15:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682679#M206659</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-09T15:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of variables with values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682696#M206667</link>
      <description>Thank you all! The variable type  is character so I used the CMISS option to count. Appreciate all your expertise.</description>
      <pubDate>Wed, 09 Sep 2020 16:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-variables-with-values/m-p/682696#M206667</guid>
      <dc:creator>lmtamina</dc:creator>
      <dc:date>2020-09-09T16:18:49Z</dc:date>
    </item>
  </channel>
</rss>

