Hi

I want to count the number of unique ID's per year and group. I have managed that with the following code:
Code:
 egen n_id_total = nvals(id), by(year, group)
However, I am also interested in counting the number of unique ID's, when condition == 1. I tried something like this:

Code:
egen n_id_total_condition = nvals(id) if condition == 1, by(year, group)
However, the above command returns missing values for observations, where condition == 0. Does anyone know a command, which allows me to assign the number of unique ID's per year/group, when condition = 1 to all observations (also those, where condition == 0)?