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?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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