01 April 2021
In R: | In Stata: |
---|---|
dt[, .(rowcount = .N), by=group] | tab group |
In R: | In Stata: |
---|---|
dt[, group_max := max(var), by=group] | by group: egen group_max = max(var) |
In R: | In Stata: |
---|---|
dt[, r_id:=seq_len(.N), by=group] | by group: g r_id = _n |
dt[, date_var := as.Date(as.character(num_date), format=”%Y%m%d”)]
dt[, yq := quarter(date_var, with_year=TRUE)
yq = quarter(parse_date_time(paste0(year, “.”, quarter), orders=”Yq”)