<?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: Displaya count of observations horizontally in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817996#M322871</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp;wrote:
&lt;P class="1655185764605"&gt;&amp;nbsp;&lt;/P&gt;
&lt;SPAN&gt;So in this case the total would be 2 since there are two observations.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. You have&amp;nbsp;&lt;STRONG&gt;one&lt;/STRONG&gt; observation containing&amp;nbsp;&lt;STRONG&gt;three&lt;/STRONG&gt; variables, of which&amp;nbsp;&lt;STRONG&gt;two&amp;nbsp;&lt;/STRONG&gt;have values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(deleted non-working code)&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2022 06:00:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-06-14T06:00:50Z</dc:date>
    <item>
      <title>Displaya count of observations horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817967#M322856</link>
      <description>&lt;PRE&gt;data have;
item1 = 'central';
item2 = '';
item3 = 'Pacific';
run;&lt;/PRE&gt;
&lt;P&gt;I want to apply a formula that gives me the total number observations by row and displays a field called row_cnt.&amp;nbsp; So in this case the total would be 2 since there are two observations.&amp;nbsp; The variables however are character in nature&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 22:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817967#M322856</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2022-06-13T22:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Displaya count of observations horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817971#M322859</link>
      <description>&lt;P&gt;Let me know if this is what you're looking for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
item1 = 'central';
item2 = '';
item3 = 'Pacific';
run;

proc sql;
	select count(name) into: total
		from dictionary.columns
		 where upcase(libname)='WORK' and upcase(memname)='HAVE';
quit;

%put &amp;amp;=total;

data have2;
	set have;
	totalvar=&amp;amp;total;
	num=totalvar-cmiss(of item:);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 23:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817971#M322859</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-13T23:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Displaya count of observations horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817980#M322863</link>
      <description>&lt;P&gt;Please show what you want the output to look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: "Observation" is SAS for "row" or "record". So your example data only has 1 observation and 2 non-missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way for what I think you are asking for:&lt;/P&gt;
&lt;PRE&gt;data have;
   item1 = 'central';
   item2 = '';
   item3 = 'Pacific';
   row_cnt = countw(catx('*',item1,item2,item3),'*');
   row_cnt2= countw(catx('*',of item:),'*');
run;&lt;/PRE&gt;
&lt;P&gt;which creates a string of your values with * between the ones that are not missing and then uses the Countw function to count how many separations are there.&lt;/P&gt;
&lt;P&gt;If you have more than 3 or 4 variables you might use an Array or a list such as the "of item:" to use all the variables whose names start with Item to build the string before counting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 02:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817980#M322863</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-14T02:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Displaya count of observations horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817996#M322871</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp;wrote:
&lt;P class="1655185764605"&gt;&amp;nbsp;&lt;/P&gt;
&lt;SPAN&gt;So in this case the total would be 2 since there are two observations.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. You have&amp;nbsp;&lt;STRONG&gt;one&lt;/STRONG&gt; observation containing&amp;nbsp;&lt;STRONG&gt;three&lt;/STRONG&gt; variables, of which&amp;nbsp;&lt;STRONG&gt;two&amp;nbsp;&lt;/STRONG&gt;have values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(deleted non-working code)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 06:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Displaya-count-of-observations-horizontally/m-p/817996#M322871</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-06-14T06:00:50Z</dc:date>
    </item>
  </channel>
</rss>

