Hello! I need help with getting counts of how many procedures were done during each admission visit for each. Different patients have different number of admission visits and procedures completed during each visit.
- The number of procedures completed is counted by the amount of times the same admission number is repeated for each enrolid.
My data looks like this;
data test;
input id admission;
datalines;
1 121
1 121
1 121
1 141
1 141
2 111
;
run;
I want an output that shows for each id, how many distinct admission each one had (which I was able to get using code below). But I want for each distinct admission numbers, how many procedures were done at (visit1 - visitn)
This is what I want my output to look like
Output;
id freq visit1 visit2 visit 3;
1 2 3 2
2 1 1
;
run;
I was able to get the freq column by using the code below and just using a proc sql to get the max count by each enrolid, but I'm struggling with getting the frequency of the procedures done for each admission. I'll appreciate any help.
data x;
set test;
by id;
if first.id then count=0;
count+1;
run;