Desktop productivity for business analysts and programmers

Count number of observations

Reply
Contributor
Posts: 73

Count number of observations

Hello SAS EG Users,

What is the best way to count number of observations in SAS dataset, when it shows question mark while scrolling from top to bottom in tooltip that generally says "x of y" where y represents total number of observations in dataset.

Proc SQL;

Select count(*)

from WORK.<datasetname>;

quit;

Can above code be used or does it need some modifications? I haven't used PROC SQL in a while Smiley Happy

Thanks,

Dhanashree

Super User
Posts: 19,157

Re: Count number of observations

Depends on what you want to do with it.

You can right click a data set, see the properties which includes the number of observations.

Your code above will print to screen.

Also, you should try your code rather than ask if it works...

Community Manager
Posts: 2,889

Re: Count number of observations

The [?] appears when accessing a VIEW or sometimes a DMBS table (via a SAS/ACCESS library) when the row count isn't available.

You can try the PROC SQL step, or perhaps glean some information from the Summary Statistics task, One-Way Frequencies task or Data Set Attributes task.  If you use Summary Statistics or One-Way Frequencies, and if the table is a DBMS table, then SAS will actually push that "counting work" down to the database, which should be more efficient.

Chris

Ask a Question
Discussion stats
  • 2 replies
  • 776 views
  • 0 likes
  • 3 in conversation