Working in SAS but using some SQL code to count the number of unique patients but also the total number of observations for a set of indicators. Each record has a patient identifier, the facility where the patient is, and a group of binary indicators (0,1) for each bed section (the particular place in the hospital where the patient is). For each patient record, only 1 bed section can have a value of '1'. Overall, patients can have multiple observations in a bed section or in other bed sections, i.e. patients can be hospitalized > 1. The idea is to roll this data set up by facility and count the total # of admissions for each bed section but also the total people for each bed section. The people count will always be <= to the observation count. Counting people was just added to my to-do list and to this point I was only summing up observations for each bed section using the code below: proc sql; create table fac_bedsect as select facility, sum(bedsect_alc) as bedsect_alc, sum(bedsect_blind) as bedsect_blind, sum(bedsect_gen) as bedsect_gen from bedsect_type group by facility; quit;
Is there a way I can incorporate into this code the # of unique people for each bed section? Thanks.
bedsect_type
? Is there a person Id ? Is a persons bedsect_* value mutually exclusive, in other words, for a given row with a person id, will only one of the variablesbedsect_alc
,bedsect_blind
,bedsect_gen
have a value ? – RichardMinimal Complete Verifiable Example
(MCVE) and Why should I provide a MCVE. We like to supply answers, but there are methods you can use to get those faster and better. – Paul Maxwellfor each bed section
meanfor each facility
? (i.e. is grouping by facility the only grouping needed?) – Paul Maxwell