Hi,

I would like to expand the data to the latest datapoint available by group ("unit_id" in my case). In my sample, a few "unit_id" have available data until 2020m5 but not all. I would like all "unit_id" to go up to that date with missing observations.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double unit_id float date double WC01001A
 1 722   4739100
 2 722   8351931
 3 722   3589427
 4 722   2321253
 6 722   1488526
 7 722   1417462
 8 722   1521587
 9 722   2406796
10 722   4911892
11 722 224945000
12 722  33766000
13 722  12807684
14 722   5581300
15 722  25868000
16 722   9039000
17 722  10333000
18 722   2784405
19 722   8200000
20 722  44655801
21 722   7982200
22 722  16265600
23 722 104260000
24 722   9709003
25 722  65122000
26 722  74639000
 1 723   4739100
 2 723   8488899
 3 723   3589427
 4 723   2321253
 6 723   1488526
 7 723   1649484
 8 723   1521587
 9 723   2408788
10 723   4911892
11 723 224945000
12 723  33715000
13 723  12807684
14 723   5628900
15 723  26037000
16 723  11505000
17 723  10333000
18 723   3553860
19 723   8200000
21 723   7982200
22 723  17066200
23 723 109262000
24 723   9709003
25 723  65122000
26 723  82220000
27 723  11587400
 1 724   4758346
 3 724   3496208
 4 724   2357914
 6 724   1727829
 7 724   1120272
 8 724   1612806
10 724   5932452
11 724 231051000
13 724  12837929
17 724  11354000
19 724   8536284
21 724   7790500
24 724   9454848
25 724  63448000
33 724 186159448
36 724   5553830
38 724   5913269
42 724   6359000
48 724   5236000
49 724   9675000
51 724  10209900
53 724  24647749
55 724  67044000
57 724   1330565
60 724   3723018
end
format %tm date
label values unit_id unit_id
label def unit_id 1 "130062", modify
label def unit_id 2 "130088", modify
label def unit_id 3 "130298", modify
label def unit_id 4 "130502", modify
label def unit_id 6 "131844", modify
label def unit_id 7 "132808", modify
label def unit_id 8 "134057", modify
label def unit_id 9 "13466Q", modify
label def unit_id 10 "13471D", modify
label def unit_id 11 "134784", modify
label def unit_id 12 "134843", modify
label def unit_id 13 "135448", modify
label def unit_id 14 "13951F", modify
label def unit_id 15 "13967E", modify
label def unit_id 16 "13967H", modify
label def unit_id 17 "14015T", modify
label def unit_id 18 "141405", modify
label def unit_id 19 "141545", modify
label def unit_id 20 "14352P", modify
label def unit_id 21 "14361V", modify
label def unit_id 22 "14698C", modify
label def unit_id 23 "14737P", modify
label def unit_id 24 "14806F", modify
label def unit_id 25 "14861V", modify
label def unit_id 26 "14863U", modify
label def unit_id 27 "152533", modify
label def unit_id 33 "154680", modify
label def unit_id 36 "261977", modify
label def unit_id 38 "26406N", modify
label def unit_id 42 "271980", modify
label def unit_id 48 "277642", modify
label def unit_id 49 "28179N", modify
label def unit_id 51 "28341F", modify
label def unit_id 53 "28513N", modify
label def unit_id 55 "286738", modify
label def unit_id 57 "28984D", modify
label def unit_id 60 "29304L", modify
Thanks for your help!