Here is R equivalent of your SAS code:
library(dplyr)
df |>
select(ID,GENDER,BIRTHYEAR) |>
group_by(ID) |>
summarize(count = n())
Where df is your dataframe. select, group_by and summarize are all dplyr verbs.
You can learn more about the R dplyr package here: https://dplyr.tidyverse.org/