Help using Base SAS procedures

counting values of variables

Reply
N/A
Posts: 0

counting values of variables

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
Contributor
Posts: 35

Re: counting values of variables

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?
Ask a Question
Discussion stats
  • 1 reply
  • 102 views
  • 0 likes
  • 2 in conversation