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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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