1) As to your queries about the syntax of COUNT function, refer to the following link:
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a002260230.htm
2) Boolean concept: When data is sorted on a particular variable (BY variable) in sas dataset, you can reference the first or last elements of the group by referencing them through first.variable and last.variable syntax.
For example let us take a part of ur dataset:
num personum
A01 1------------------ first.num
A01 2
A01 3
A01 4------------------ last.num
A02 1------------------ first.num
A02 2
A02 3
A02 4------------------ last.num
If you want to remove duplicates you can use PROC SORT with NODUPKEY.
But if you want to count duplicates you have to put your own logic. COUNT procedure does not do what you want, it will count the number of times that a specific substring of characters appears within a character string that you specify.
A sample logic that will do what you want might be:
I take that your dataset is already sorted BY num personum
data temp;
set err;
person=num||personum;
run;
proc sort; by person; run; (this might be redundant but still)
data temp;
set temp; by personum;
cnt=0;
if not first.personum then cnt = cnt + 1;
run;
The dataset temp will have a new variable "cnt" which will have the number of duplicate ocurrences of a particular combination num and personum.
A better way to do it might be:
data temp;
set err; by num personum;
cnt=0;
if first.num and not (first.personum) then cnt = cnt + 1;
Hope this helps.