Each row is considered an admission to the facility, having a patient SSN attached to it. I also need to determine how many patients per restraint per facility. This would be determined by how many different social security numbers per restraint per facility ID , and somehow doing a count function.
The data is similar to this….
proc sort data=sample ;
by facility_id ;
*if your data already sorted by facility_id, you don't need sort it again.;
* in the result, the restr1 will be the freqency restr1 in (0 1), the restr1_count will be the freqency for restr1=1;
* same for restr2;
*if there are no missing values exist, restr1 will be equqal to restr2;
drop count1 count2 ssn;
if first.facility_id then do;
if restr1 eq 1 then restr1_count+1;
else if restr1 eq 0 then count1+1;
if restr2 eq 1 then restr2_count+1;
else if restr2 eq 0 then count2+1;
if last.facility_id then do;