SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

Hello,

In SAS EG, is there a way to use the statement count(distinct flob) over (partition by police) as N, like the example for test3 (see code below) and if so, how ?

data test;
   input police $ flob $ Other_info $;
   datalines;
1 A X1
1 B X1
1 C X1
1 D X1
1 E X1
2 A TR
2 C TR
;
RUN;

PROC SQL;
create table test1 as
select *,
		count(distinct flob) as N
from test
group by police;
QUIT;

PROC SQL;
create table test2 as
select *,
		count(distinct flob) over (partition by police) as N
from test;
QUIT;

 

Regards, 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

No.

But you don't need it in SAS.

Just use your first example with the normal GROUP BY and SAS will remerge the count onto the appropriate values of A.

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

No.

But you don't need it in SAS.

Just use your first example with the normal GROUP BY and SAS will remerge the count onto the appropriate values of A.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 860 views
  • 2 likes
  • 2 in conversation