<?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: Counting missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746211#M234066</link>
    <description>&lt;P&gt;Please show us the ENTIRE log, with nothing chopped out. Please click on the &amp;lt;/&amp;gt; icon and paste your log as text into the window that appears.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jun 2021 12:02:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-07T12:02:26Z</dc:date>
    <item>
      <title>Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746188#M234053</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following data:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
  input id var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12;
cards;
A	1 2 3 . . . . . 1 1 1 3
B	3 3 2 1 3 2 1 . . . . .
C	. . . . 1 2 3 1 2 3 2 .
D	. . . . 3 1 1 . 3 . 1 .
E	. . . . 1 3 1 3 1 3 . .
F	3 2 1 . . . . . 1 1 1 3

; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And I want to count the number of missing values, however I want to start counting only when we start having values. For example, I want the following output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID Number of missing values:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;B 5&amp;nbsp;&lt;/P&gt;
&lt;P&gt;C 1&lt;/P&gt;
&lt;P&gt;D 3&lt;/P&gt;
&lt;P&gt;E 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;F 5&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 10:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746188#M234053</guid>
      <dc:creator>dmarques1998</dc:creator>
      <dc:date>2021-06-07T10:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746190#M234055</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set  example;
array vars{*} var1-var12;
nomiss = 0;
number_miss = 0;
do _n_ = 1 to dim(vars);
  if vars{_n_} then nomiss = 1;
  if nomiss and vars{_n_} = . then number_miss + 1;
end;
drop nomiss;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, posted from my tablet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;Edit: fixed a typo (thrn -&amp;gt; then)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 11:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746190#M234055</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-07T11:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746195#M234058</link>
      <description>From that way, it is counting all the missing values!</description>
      <pubDate>Mon, 07 Jun 2021 11:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746195#M234058</guid>
      <dc:creator>dmarques1998</dc:creator>
      <dc:date>2021-06-07T11:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746197#M234059</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376436"&gt;@dmarques1998&lt;/a&gt;, did you even try the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;? It gives the exact answer you want (after correcting a typographical error).&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 11:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746197#M234059</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-07T11:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746198#M234060</link>
      <description>yes, and adapting to my code, give me the exact number of missing values, and not the number of missing values that I want</description>
      <pubDate>Mon, 07 Jun 2021 11:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746198#M234060</guid>
      <dc:creator>dmarques1998</dc:creator>
      <dc:date>2021-06-07T11:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746201#M234062</link>
      <description>&lt;P&gt;Okay, you said:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;For example, I want the following output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID Number of missing values:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;B 5&amp;nbsp;&lt;/P&gt;
&lt;P&gt;C 1&lt;/P&gt;
&lt;P&gt;D 3&lt;/P&gt;
&lt;P&gt;E 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;F 5&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and those are the numbers I see when I run the code.&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="Capture.PNG" style="width: 204px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60078iFD4E774A7674A19C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're not getting the above answers, then show us the exact code you are using.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 11:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746201#M234062</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-07T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746210#M234065</link>
      <description>this is the Note/warning that appear in the log : &lt;BR /&gt;&lt;BR /&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;BR /&gt;      30:6   &lt;BR /&gt;NOTE: Invalid numeric data, 'XXXX' , at line 30 column 6.&lt;BR /&gt;NOTE: Invalid numeric data, 'XXXXX' , at line 30 column 6.&lt;BR /&gt;WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.</description>
      <pubDate>Mon, 07 Jun 2021 11:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746210#M234065</guid>
      <dc:creator>dmarques1998</dc:creator>
      <dc:date>2021-06-07T11:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746211#M234066</link>
      <description>&lt;P&gt;Please show us the ENTIRE log, with nothing chopped out. Please click on the &amp;lt;/&amp;gt; icon and paste your log as text into the window that appears.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 12:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746211#M234066</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-07T12:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746214#M234067</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
infile cards expandtabs truncover;
  input id $ var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12;
cards;
A	1 2 3 . . . . . 1 1 1 3
B	3 3 2 1 3 2 1 . . . . .
C	. . . . 1 2 3 1 2 3 2 .
D	. . . . 3 1 1 . 3 . 1 .
E	. . . . 1 3 1 3 1 3 . .
F	3 2 1 . . . . . 1 1 1 3
; 
options missing='.';
data want;
 set example;
 want=lengthn(scan(cats(of var:),-1,,'d'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jun 2021 12:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746214#M234067</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-06-07T12:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746216#M234069</link>
      <description />
      <pubDate>Mon, 07 Jun 2021 12:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746216#M234069</guid>
      <dc:creator>dmarques1998</dc:creator>
      <dc:date>2021-06-07T12:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746219#M234072</link>
      <description>&lt;P&gt;Did it&amp;nbsp;&lt;STRONG&gt;EVER&lt;/STRONG&gt; occur to you that the &lt;STRONG&gt;type&lt;/STRONG&gt; of variables&amp;nbsp;&lt;EM&gt;might&lt;/EM&gt; be important??&lt;/P&gt;
&lt;P&gt;I can only develop code for data that I see; if you want to play practical jokes, I'm outta here.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 12:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746219#M234072</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-07T12:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746221#M234073</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376436"&gt;@dmarques1998&lt;/a&gt;&amp;nbsp;. Obviously, you are not working with the data that you showed in your original post. We would need to see (a portion of) your actual data, provided as you have done previously as SAS data step code.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 12:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746221#M234073</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-07T12:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Counting missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746226#M234075</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376436"&gt;@dmarques1998&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you're working with &lt;EM&gt;character&lt;/EM&gt; variables. An alternative to using a DO loop (which is a perfectly valid approach) is to use SAS functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (id var1-var12)($);
cards;
A	1 2 3 . . . . . 1 1 1 3
B	3 3 2 1 3 2 1 . . . . .
C	. . . . 1 2 3 1 2 3 2 .
D	. . . . 3 1 1 . 3 . 1 .
E	. . . . 1 3 1 3 1 3 . .
F	3 2 1 . . . . . 1 1 1 3
G	. . . . . . . . . . . .
H	1 1 1 1 1 1 1 1 1 1 1 1
;

data want;
set have;
array _v[*] var1-char-var12; /* name range list, assuming that real variable names are not var1 etc. */
if cmiss(of _v[*])=dim(_v) then n_miss=.; /* or whatever you want n_miss to be in this case */
else n_miss=cmiss(of _v[*])-whichc(coalescec(of _v[*]), of _v[*])+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jun 2021 12:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-missing-values/m-p/746226#M234075</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-06-07T12:33:40Z</dc:date>
    </item>
  </channel>
</rss>

