E.g.: I want the date of the first and last hospital admission for every patient in my table
year, to take the sum of a
costvariable to create a new variable that represents the total cost for each patient over a given year.
encounter_dateof each patient; in other words, partitioned on
patient_id. This will create two new variables,
max_encounter_datefor each patient. When we run this query, note that no records will be dropped; rather, these new variables will be have consistent values for any given
min_encounter_date = encounter_dateOR
max_encounter_date = encounter_date!
year) when defining our partition.