BookmarkSubscribeRSS Feed
deleted_user
Not applicable
How do I count the values of a variable for a particular customerid?
Example;
I need to count the value of void & smoke for distinct customers

Customerid void smoke
12001 1 2
12001 1 4
12001 1 3
12004 1 2
12004 1 4
12005 1 3
12005 1 3
12005 1 2
12006 1 4
12006 1 3
12007 1 2
12007 1 4
12007 1 3
12007 1 3

I have around 9999 obs in the datasets.
I tried PROC SQL but didn't get expected results.
Any help would be appreciated.
Thanx.
Priya
1 REPLY 1
rab24
Calcite | Level 5
PROC SQL;
CREATE TABLE count AS SELECT Customeroid,
(count(void) + count(smoke)) AS count
FROM WORK.Data AS Data
GROUP BY customeroid;
QUIT;

gives a count like this

12001 6
12004 6
12005 4
12006 4
12007 8

Is that what you were expecting or the results you didn't want?

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 979 views
  • 0 likes
  • 2 in conversation