<?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 the number of observations in a data frame in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293324#M61015</link>
    <description>&lt;P&gt;Yeah. NROW(x) is IML code. if you are familiar with R ,then IML is every familiar with you . Here are two ways to know how much number of obs there are in a data frame/dataset/table :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 1) IML code: */
proc iml;
 use sashelp.class nobs nobs;
 read all var{age} into x;
 close;

 print nobs;
 print (nrow(x));
quit;

/* 2) Data Step: */

data _null_;
 set sashelp.class nobs=nobs;
 put nobs=;
 stop;
run;

/* 
  proc contents can also give you 
  all the information about that data frame / table . 
*/

proc contents data=sashelp.class varnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2017 12:41:46 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-07-05T12:41:46Z</dc:date>
    <item>
      <title>How to count the number of observations in a data frame</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293167#M60943</link>
      <description>&lt;P&gt;Hello, I am using SAS Enterprise Guide. I'd like to do some quick exploratory analysis of a data set that's already loaded in my work library, however when I run the code below I get the error message "Statement is not valid or is used out of proper order".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NROW(dataset);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would also be very interested in learning what people's favorite EDA functions are, wish there was a SAS equivalent of the str() function in R.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 15:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293167#M60943</guid>
      <dc:creator>Hadrien</dc:creator>
      <dc:date>2016-08-22T15:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of observations in a data frame</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293169#M60944</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Errm, NROW() is a SAS IML function, needs to be in an IML statement. &amp;nbsp;There are many ways to find out number of observations, you could open the dataset and look, inspect its properties, do a data set statement and look at the log, proc sql count(*), proc means, proc freq, proc tabulate etc.&lt;/P&gt;
&lt;P&gt;For EDA - see above procedures. &amp;nbsp;The R str() function returns attributes on the data yes? &amp;nbsp;If so then proc contents does the same, or look at the vcolumn/table in sashelp.library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To add, do you know SAS at all? &amp;nbsp;You will need to learn the language and way of working to be able to pretty much anything, much like any programming language.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 15:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293169#M60944</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-22T15:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of observations in a data frame</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293324#M61015</link>
      <description>&lt;P&gt;Yeah. NROW(x) is IML code. if you are familiar with R ,then IML is every familiar with you . Here are two ways to know how much number of obs there are in a data frame/dataset/table :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 1) IML code: */
proc iml;
 use sashelp.class nobs nobs;
 read all var{age} into x;
 close;

 print nobs;
 print (nrow(x));
quit;

/* 2) Data Step: */

data _null_;
 set sashelp.class nobs=nobs;
 put nobs=;
 stop;
run;

/* 
  proc contents can also give you 
  all the information about that data frame / table . 
*/

proc contents data=sashelp.class varnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/293324#M61015</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-05T12:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of observations in a data frame</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/295169#M61657</link>
      <description>&lt;P&gt;My IT dept just confirmed we don't have a license for IML, which is why it wasn't working. Didn't realize there was different SAS functions for their different products.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/295169#M61657</guid>
      <dc:creator>Hadrien</dc:creator>
      <dc:date>2016-08-30T14:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of observations in a data frame</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/295185#M61664</link>
      <description>&lt;PRE&gt;
proc contents can give you all the information about that data frame / table .


proc contents data=sashelp.class varnum;
run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/295185#M61664</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-30T14:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the number of observations in a data frame</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/405362#M98607</link>
      <description>&lt;P&gt;/* Here's a trick I occasionally&amp;nbsp;use. Note only one record is read form each dataset but SAS magic knows all… */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data my_dataset ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;do I=1 to 27 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;output ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;end ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data my_dataset2 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;do I=1 to 73 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;output ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;end ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; set my_dataset(obs=1) nobs=nobs ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; call symputx('records',nobs) ;&lt;BR /&gt;run ;&lt;BR /&gt;%put records: &amp;amp;records ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Here SAS knows how many obs are in the concatenated datasets too… */&lt;BR /&gt;data _null_ ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; set my_dataset(obs=1) my_dataset2(obs=1) nobs=nobs ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; call symputx('records',nobs) ;&lt;BR /&gt;run ;&lt;BR /&gt;%put Concatenated records: &amp;amp;records ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Log file:&lt;BR /&gt;NOTE: The data set WORK.MY_DATASET has 27 observations and 1 variables.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: The data set WORK.MY_DATASET2 has 73 observations and 1 variables.&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.MY_DATASET.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;records: 27&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: There were 1 observations read from the data set WORK.MY_DATASET.&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.MY_DATASET2.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Concatenated records: 100&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 21:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-the-number-of-observations-in-a-data-frame/m-p/405362#M98607</guid>
      <dc:creator>strmwzrd</dc:creator>
      <dc:date>2017-10-18T21:14:05Z</dc:date>
    </item>
  </channel>
</rss>

