<?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: It's insane there is no character version of N in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862883#M340840</link>
    <description>&lt;P&gt;I think that what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438688"&gt;@toomanystepsint&lt;/a&gt;&amp;nbsp;is referring to is what's available in the datastep. There is a CMISS function (counts the number of missing character values), but AFAIK not anything corresponding to the N function for numeric values:&lt;/P&gt;
&lt;PRE&gt;119  data _null_;
120    length test1-test3 $1;
121    test2='a';
122    nmiss=cmiss(of test1-test3);
123    n=n(of test1-test3);
124    put n= nmiss=;
125  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      123:15
NOTE: Variable test1 is uninitialized.
NOTE: Variable test3 is uninitialized.
NOTE: Invalid numeric data, test2='a' , at line 123 column 15.
n=0 nmiss=2
test1=  test2=a test3=  nmiss=2 n=0 _ERROR_=1 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Mar 2023 08:57:29 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2023-03-08T08:57:29Z</dc:date>
    <item>
      <title>It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862740#M340780</link>
      <description>&lt;P&gt;How stupid is it that SAS can't count non-missing character fields? Just insane, worthless software.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862740#M340780</guid>
      <dc:creator>toomanystepsint</dc:creator>
      <dc:date>2023-03-07T17:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862742#M340782</link>
      <description>&lt;P&gt;If you have a programming question please provide example input data and the expected result.&lt;/P&gt;
&lt;P&gt;Show the code you tried and if you got an error show the log with the code and error.&lt;/P&gt;
&lt;P&gt;If you did not get the expected result then show the result you got and explain why it is not what you wanted.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862742#M340782</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T17:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862767#M340793</link>
      <description>&lt;P&gt;Have you tried using N on character variables? It works just fine, as does COUNT:&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
  set sashelp.class;
  if _N_ &amp;lt; 5 then name = '';
run;

proc sql;
  select  sum(not missing(name))
         ,n(name)
		 ,count(name)
		 ,count(*)
  from class;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 19:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862767#M340793</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-03-07T19:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862883#M340840</link>
      <description>&lt;P&gt;I think that what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438688"&gt;@toomanystepsint&lt;/a&gt;&amp;nbsp;is referring to is what's available in the datastep. There is a CMISS function (counts the number of missing character values), but AFAIK not anything corresponding to the N function for numeric values:&lt;/P&gt;
&lt;PRE&gt;119  data _null_;
120    length test1-test3 $1;
121    test2='a';
122    nmiss=cmiss(of test1-test3);
123    n=n(of test1-test3);
124    put n= nmiss=;
125  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      123:15
NOTE: Variable test1 is uninitialized.
NOTE: Variable test3 is uninitialized.
NOTE: Invalid numeric data, test2='a' , at line 123 column 15.
n=0 nmiss=2
test1=  test2=a test3=  nmiss=2 n=0 _ERROR_=1 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2023 08:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862883#M340840</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-03-08T08:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862901#M340854</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438688"&gt;@toomanystepsint&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How stupid is it that SAS can't count non-missing character fields? Just insane, worthless software.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Like with any other software there isn't always a ready-made function that does exactly what you want for a specific problem. There is always a way to get what you need by combining existing functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is a function "missing" that you really would want to use regularly then you can always use Proc FCMP and write your own custom function and store it permanently for reuse.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 11:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862901#M340854</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-03-08T11:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862939#M340885</link>
      <description>&lt;P&gt;Well, of course SAS can count non-missing character variables, but you're right that there is no function provided for that purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a SASware ballot item recommending this function be added.&amp;nbsp; Would encourage you to upvote:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-Character-Version-of-N-Function/idi-p/397120" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-Character-Version-of-N-Function/idi-p/397120&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also this tech support note shows SAS agrees this is a gap:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/kb/46/235.html" target="_blank" rel="noopener"&gt;https://support.sas.com/kb/46/235.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But both the ballot item and the tech support note are several years old.&amp;nbsp; So hard to know if adding this function is on a roadmap or not.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 13:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/862939#M340885</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-08T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/863023#M340914</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438688"&gt;@toomanystepsint&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How stupid is it that SAS can't count non-missing character fields? Just insane, worthless software.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How&amp;nbsp; many "fields"? Length of each? If enough values might have to define a long enough value to hold a concatenated string instead of the inline call to catx below.&lt;/P&gt;
&lt;P&gt;Replace "of _character" below with&amp;nbsp; a comma separated list of variable names or even explicit strings.&lt;/P&gt;
&lt;PRE&gt;data junk;
   set have;
   nstr= countw(catx('~',of _character_),'~');
run;&lt;/PRE&gt;
&lt;P&gt;The "trick" is to have a single character that you know does not appear in the values so catx can place a single character between values so the Countw function can tell where each value ends. Since CATX removes leading and trailing blanks before inserting the delimiter value in the first position then no such delimiter is inserted when the value is all blanks or missing. So the delimited list has "words" or non-missing variable values.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 16:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/863023#M340914</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-08T16:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: It's insane there is no character version of N</title>
      <link>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/863174#M340985</link>
      <description>&lt;P&gt;As Quentin points out, if you can count the number of missing values in a set of k variables (by using CMISS), then you automatically get the number of nonmissing values by subtracting that number from k.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Outside of the DATA step:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You can &lt;A href="https://blogs.sas.com/content/iml/2011/09/19/count-the-number-of-missing-values-for-each-variable.html" target="_self"&gt;use PROC FREQ to count the number of missing values for both numeric and character variables&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;In the SAS IML language, you can &lt;A href="https://blogs.sas.com/content/iml/2011/09/19/count-the-number-of-missing-values-for-each-variable.html" target="_self"&gt;use the COUNTMISS and COUNTN functions to count missing and nonmissing values&lt;/A&gt;, respectively.&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 13:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/It-s-insane-there-is-no-character-version-of-N/m-p/863174#M340985</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-03-09T13:20:42Z</dc:date>
    </item>
  </channel>
</rss>

