<?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: Is there any way to count the number of missing and non-missing values for character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642362#M191602</link>
    <description>&lt;P&gt;Thank Tom, this works like a charm. I need the former approach and noted the result shows the non missing count, but is there anyway to show the missing count as well?&lt;/P&gt;</description>
    <pubDate>Thu, 23 Apr 2020 18:36:12 GMT</pubDate>
    <dc:creator>LL5</dc:creator>
    <dc:date>2020-04-23T18:36:12Z</dc:date>
    <item>
      <title>Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642350#M191593</link>
      <description>&lt;P&gt;I am trying to count the total number of missing and non missing values for each character variables.&lt;/P&gt;&lt;P&gt;below is the sample data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (disp1-disp8) ($); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 2 . 4 5 6 7 8&lt;/P&gt;&lt;P&gt;. 2 3 4 5 . 7 8&lt;/P&gt;&lt;P&gt;1 2 3 4 5 6 7 8&lt;/P&gt;&lt;P&gt;1 2 3 . . 6 . 8&lt;/P&gt;&lt;P&gt;1 2 3 4 5 6 7 8&lt;/P&gt;&lt;P&gt;1 . 3 . 5 . 7 .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;My goal is to try to get the following result.&amp;nbsp;Is there anyway to do it for character variable? Thanks.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Missing&lt;/TD&gt;&lt;TD&gt;Non Missing&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp5&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp6&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp7&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;disp8&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642350#M191593</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-04-23T18:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642352#M191594</link>
      <description>&lt;P&gt;Do you want to count the number of non-missing values? Or the number of DISTINCT non-missing values?&lt;/P&gt;
&lt;P&gt;The NLEVELS option on PROC FREQ will do the latter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq nlevels;
  tables disp1-disp8 / noprint;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the former you can also use PROC FREQ but first make a user defined format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $cmiss ' '='Missing' other='Non-missing';
run;
proc freq ;
 tables disp1-disp8;
 format disp1-disp8 $cmiss.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642352#M191594</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-23T18:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642362#M191602</link>
      <description>&lt;P&gt;Thank Tom, this works like a charm. I need the former approach and noted the result shows the non missing count, but is there anyway to show the missing count as well?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642362#M191602</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-04-23T18:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642366#M191604</link>
      <description>&lt;P&gt;You probably need to add the missing option the TABLES statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tables disp1-disp8 / missing;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642366#M191604</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-23T18:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642371#M191607</link>
      <description>&lt;P&gt;If you want to get the exact output to your original want, try this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data trans_v(keep=vname miss nmiss)/view=trans_v;
	length vname $5 nmiss miss 4;
	set temp;
	array disps {8} $ disp1-disp8;
	label nmiss='Non Missing' 
		  miss='Missing'
		  ;

	do i=1 to 8;
		call missing(miss,nmiss);
		if (missing(disps{i})) then miss=1;
		else nmiss=1;
		vname=vname(disps{i});
		output; 
	end;
run;
proc summary data=trans_v nway missing;
	class	vname;
	var		miss nmiss;
	output out=stats(drop=_:) sum=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ahmed&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642371#M191607</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2020-04-23T18:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642372#M191608</link>
      <description>&lt;P&gt;Thank you Tom.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642372#M191608</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-04-23T18:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642385#M191616</link>
      <description>&lt;DIV class="sas-author-rank"&gt;&lt;SPAN&gt;Thanks AhmedAI_Attar, this is an awesome approach. &lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Apr 2020 19:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642385#M191616</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-04-23T19:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642398#M191624</link>
      <description>&lt;P&gt;I have one more question, why do we need call missing(miss,nmiss) here?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 20:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642398#M191624</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-04-23T20:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642418#M191637</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89004"&gt;@LL5&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have one more question, why do we need call missing(miss,nmiss) here?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would suggest running that data step without that statement and compare to the results you get with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It resets the values of those variable to missing for each step of the loop.&lt;/P&gt;
&lt;P&gt;Otherwise you have values from the previous steps that had been set to 1 when i is &amp;gt; 1.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 23:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642418#M191637</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-23T23:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to count the number of missing and non-missing values for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642572#M191715</link>
      <description>&lt;P&gt;Thanks Ballardw. I ran the data step without the call missing step and noted the number for miss and nmiss variables are kind of&amp;nbsp;accumulating.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 13:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-count-the-number-of-missing-and-non-missing/m-p/642572#M191715</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2020-04-24T13:15:09Z</dc:date>
    </item>
  </channel>
</rss>

