BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is there in SAS function to return records count of the table?
4 REPLIES 4
deleted_user
Not applicable
Data X;
A=1;
;
Run;

Proc SQL;
Create table COUNT as select * from dictionary.tables
Where Libname='WORK' and memname='X';
Quit;
deleted_user
Not applicable
Thanks.

If I want only distinct records (by Field1), I must execute 2 queries?

create table test as (
select distinct Field1, Field2, Field3 from Table1
);


and after

select count(*) into: COUNT from test;

Or I can do it in one step?
deleted_user
Not applicable
Sorry for stupid question

the solution is

select count(Field1) as COUNT, Field2, Field3 from Table1

Am I right?
deleted_user
Not applicable
I think you need something like this:

proc sql;
create table NEW_TABLE as
select Field1, Field2, Field3
count(Field3) as COUNT3,
count(Field2) as Count2,
count(distinct Field1) as Count1_DISTINCT
from YOUR_TABLE;
quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1382 views
  • 0 likes
  • 1 in conversation