<?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 all the miss values for an entire observation, taking into consideration the 0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323725#M71793</link>
    <description>Interesting method.... But, when the database present a value like '200', the function will detect 2 extra missings thanks to the 0.</description>
    <pubDate>Tue, 10 Jan 2017 18:13:18 GMT</pubDate>
    <dc:creator>Feragon42</dc:creator>
    <dc:date>2017-01-10T18:13:18Z</dc:date>
    <item>
      <title>How to count all the miss values for an entire observation, taking into consideration the 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323683#M71773</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;Today I come with this problem that I hope you can help me.&lt;/P&gt;&lt;P&gt;Let's say that I have this dataset:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A $ B C D $;
datalines;
try 0 57 0
do . 42 something
with 442 . this
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I need to return this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6651i8630150263B946F0/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Captura.PNG" title="Captura.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new variable, N_MISS, count how many missing character I have in every observation. I know &amp;nbsp;can do this easily with the function CMISS(OF A-D), but the problem is that I need to consider the 0 as a missing value.&lt;/P&gt;&lt;P&gt;I create a format to identify with 0 and 1 when the value are missing or not, and then sum al the variables of the observation and have the amount of not missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT LIBRARY = FORMATS;
	INVALUE $CMISS_COUNT '0' = 0
	                     ' ' = 0
		             '.' = 0
			     OTHER = 1;
	INVALUE NMISS_COUNT 0 = 0
			    . = 0
			    OTHER = 1;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But, when I apply a format, the value of the character still the same for the sum. I can use the fuction PUT(A, $CMISS_COUNT.), but in the real excercise in don't have only 4 variables but 250 ... aaaaand do that 250 times is... well.&lt;/P&gt;&lt;P&gt;I hope I can express myself, sorry for my newbie english.&lt;/P&gt;&lt;P&gt;Goodbye, and thanks for all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 15:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323683#M71773</guid>
      <dc:creator>Feragon42</dc:creator>
      <dc:date>2017-01-10T15:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to count all the miss values for an entire observation, taking into consideration the 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323690#M71777</link>
      <description>&lt;P&gt;You can use the translate function in cmiss but you won't be able to use the "of" notation. Or you create a separate array of temporary variables that you apply translate to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data junk;
   x = '0';
   y = '123';
   z = ' ';
   nmiss = cmiss(translate(x,' ','0'),y,z);
run;&lt;/PRE&gt;
&lt;P&gt;This approach does have a potential issue in that it will treat '0000' as missing as well. If that is not desired and the value appears in your data then you may be better off creating an array of temporary variables with some logic involving If/then for exactly '0'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 16:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323690#M71777</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-10T16:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to count all the miss values for an entire observation, taking into consideration the 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323700#M71783</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
    set have;
    array nvars{*} _numeric_;
    array cvars{*} _character_;
    do i = 1 to dim(nvars);
        n_miss = sum(n_miss, (nvars(i) in (., 0)));
    end;
    do j = 1 to dim(cvars);
        c_miss = sum(c_miss, (cvars(j) in ('.', '0')));
    end;
    all_miss = sum(n_miss, c_miss);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2017 16:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323700#M71783</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-01-10T16:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to count all the miss values for an entire observation, taking into consideration the 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323714#M71788</link>
      <description>&lt;P&gt;I can't test this right at the moment, but what about something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  total=countc(cats(of a--d),'.0');
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2017 17:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323714#M71788</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-10T17:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to count all the miss values for an entire observation, taking into consideration the 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323722#M71791</link>
      <description>&lt;P&gt;Excelent, this works. Very thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 18:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323722#M71791</guid>
      <dc:creator>Feragon42</dc:creator>
      <dc:date>2017-01-10T18:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to count all the miss values for an entire observation, taking into consideration the 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323725#M71793</link>
      <description>Interesting method.... But, when the database present a value like '200', the function will detect 2 extra missings thanks to the 0.</description>
      <pubDate>Tue, 10 Jan 2017 18:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-all-the-miss-values-for-an-entire-observation/m-p/323725#M71793</guid>
      <dc:creator>Feragon42</dc:creator>
      <dc:date>2017-01-10T18:13:18Z</dc:date>
    </item>
  </channel>
</rss>

