以下示例數據包含描述多位玩家下注的變量。Stata:首次出現次數,變量唯一出現次數總和
我該如何計算每個玩家的第一個bettype,第一個betprice,足球投注數量,棒球投注數量,每個客戶的獨特價格數量以及每個用戶名的唯一投注類型數量?
clear
input str16 username str40 betdate stake str16 bettype betprice str16 sport
player1 "12NOV2008 12:04:33" 90 SGL 5 SOCCER
player1 "04NOV2008:09:03:44" 30 SGL 4 SOCCER
player2 "07NOV2008:14:03:33" 120 SGL 5 SOCCER
player1 "05NOV2008:09:00:00" 50 SGL 4 SOCCER
player1 "05NOV2008:09:05:00" 30 DBL 3 BASEBALL
player1 "05NOV2008:09:00:05" 20 DBL 4 BASEBALL
player2 "09NOV2008:10:05:10" 10 DBL 5 BASEBALL
player2 "15NOV2008:15:05:33" 35 DBL 5 BASEBALL
player1 "15NOV2008:15:05:33" 35 TBL 5 BASEBALL
player1 "15NOV2008:15:05:33" 35 SGL 4 BASEBALL
end
generate double timestamp=clock(betdate,"DMY hms")
format timestamp %tc
generate double dateonly=date(betdate,"DMY hms")
format dateonly %td
generate firsttype
generate firstprice
generate soccercount
generate baseballcount
generate uniquebettypecount
generate uniquebetpricecount