<?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 the variable rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437785#M109085</link>
    <description>I need the not missing also I cannot use proc means bc my variable has characteristics and numeric part as above.</description>
    <pubDate>Thu, 15 Feb 2018 21:00:20 GMT</pubDate>
    <dc:creator>mona4u</dc:creator>
    <dc:date>2018-02-15T21:00:20Z</dc:date>
    <item>
      <title>counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437752#M109066</link>
      <description>&lt;P&gt;I have a variable and I need to count how many rows in that variable each time I run the program&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a good way to do it ??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437752#M109066</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-02-15T20:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437757#M109069</link>
      <description>&lt;P&gt;As silly as it might seem, you&amp;nbsp;have to give an example.&amp;nbsp; There are a couple of ways to interpret the result that you would like.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437757#M109069</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-15T20:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437758#M109070</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a variable and I need to count how many rows in that variable each time I run the program&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need a good way to do it ??&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"how many rows in that variable" isn't very clear. Variables do no contain "rows" generally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Details. Do you need to know the number observations in the data set, non-missing for a specific variable, non-missing for multiple variables and/or the number of different values for a variable and how many times they occur? And do you need this in a data set or report?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It really helps to provide a small example of data and what the result should be.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437758#M109070</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-15T20:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437761#M109072</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&amp;nbsp;Before jumping to the forum for help, you could google search basic options etc that has various sources with answers for your question. It's only fair to demonstrate your effort before asking very very fundamental questions although apparently some people do have the time to answer all of it no matter how simple it is.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437761#M109072</guid>
      <dc:creator>MarkWik</dc:creator>
      <dc:date>2018-02-15T20:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437766#M109076</link>
      <description>&lt;P&gt;this is the variable that&amp;nbsp; I have&amp;nbsp; and I need to know how many rows are in this variable from obs 1 which is 1000 to last one 5009&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a function or do loop that can count the number of rows.&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Site Number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1050&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1250&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1252&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1351&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1401&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1450&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1451&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&g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D&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5008&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5009&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437766#M109076</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-02-15T20:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437768#M109077</link>
      <description>&lt;P&gt;For practical purposes, this would do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have nobs=_nobs_;&lt;/P&gt;
&lt;P&gt;put 'Number of rows is ' _nobs_;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Technically, there are rare cases where this will get you the wrong answer and require a more complex program.&amp;nbsp; It's inconceivable that you would run into one of those rare cases.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437768#M109077</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-15T20:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437772#M109079</link>
      <description>I need to count the number of observation in one variable not in the whole set</description>
      <pubDate>Thu, 15 Feb 2018 20:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437772#M109079</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-02-15T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437774#M109081</link>
      <description>&lt;P&gt;if you don't want to help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;please stay silent&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437774#M109081</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-02-15T20:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437777#M109083</link>
      <description>&lt;P&gt;The number of observations is constant.&amp;nbsp; It has no relationship to which variable or variables you look at.&amp;nbsp; If you don't want the number of observations in the entire data set, you will need to add more detail about what you want.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437777#M109083</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-15T20:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437778#M109084</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt; wrote:&lt;BR /&gt;I need to count the number of observation in one variable not in the whole set&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You still have clarified if you need the number of times your variable is not missing or just row count in the data set.&lt;/P&gt;
&lt;P&gt;Please see this example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   input x;
datalines;
1
2
3
.
4
5
6
;
run;

Proc means data=example n nmiss;
var x;
run;&lt;/PRE&gt;
&lt;P&gt;There is one missing value for the variable x. So do you want the n value of 6 or 7 (which is the number of rows of the data set and has nothing whatever to do with the variable x) or something else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: proc means won't work with character variables but there are approaches depending on what you actually want.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437778#M109084</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-15T20:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437785#M109085</link>
      <description>I need the not missing also I cannot use proc means bc my variable has characteristics and numeric part as above.</description>
      <pubDate>Thu, 15 Feb 2018 21:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437785#M109085</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-02-15T21:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437788#M109087</link>
      <description>&lt;P&gt;Since there's a small data set, and interest in just the one variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have end=done;&lt;/P&gt;
&lt;P&gt;where site_number &amp;gt; ' ';&lt;/P&gt;
&lt;P&gt;if done then put 'Number of nonmissing rows is ' _n_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 21:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/437788#M109087</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-15T21:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: counting the variable rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/446485#M112024</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Might as well add some SQL examples to the mix...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.test;
   input mynum 11.0;
datalines;
1
2
3
4
5
6
7
8
8
8
9
9
10
11





run;

/* Count the observations */
proc sql;
   select count(*) from work.test;
quit;

/* Count the distinct values */
proc sql;
   select count(*) from (select distinct mynum from work.test);
quit;

/* Distinct values with the number of times each occurs */
proc sql;
   select mynum, count(*) 
      from work.test
    group by mynum;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes,&lt;/P&gt;
&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 20:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-the-variable-rows/m-p/446485#M112024</guid>
      <dc:creator>JBailey</dc:creator>
      <dc:date>2018-03-17T20:40:07Z</dc:date>
    </item>
  </channel>
</rss>

