Dear Statalisters,

I have a dataset that records firm's IDs and its ratings. Only rating changes are recorded, so if there is no record, that means the ratings haven't change.
Following is the data that I currently have
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id month) int year str2 rating
1  1 2000 "A" 
1  3 2000 "A-"
1 12 2000 "A" 
1  4 2002 "B+"
1  5 2002 "A" 
1  9 2002 "B-"
end
Now I want to create a data with the ratings for all periods that are not recorded. For example, for firm 1, ratings for 2/2000 will be similar to its latest rating available before 2/2000, which is the rating in 1/2000 (A).
Following is data that I want to achieve:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id month) int year str2 rating
1  1 2000 "A" 
1  2 2000 "A" 
1  3 2000 "A-"
1  4 2000 "A-"
1  5 2000 "A-"
1  6 2000 "A-"
1  7 2000 "A-"
1  8 2000 "A-"
1  9 2000 "A-"
1 10 2000 "A-"
1 11 2000 "A-"
1 12 2000 "A" 
1  1 2001 "A" 
1  2 2001 "A" 
1  3 2001 "A" 
1  4 2001 "A" 
1  5 2001 "A" 
1  6 2001 "A" 
1  7 2001 "A" 
1  8 2001 "A" 
1  9 2001 "A" 
1 10 2001 "A" 
1 11 2001 "A" 
1 12 2001 "A" 
1  1 2002 "A" 
1  2 2002 "A" 
1  3 2002 "B+"
1  4 2002 "B+"
1  5 2002 "A" 
1  6 2002 "A" 
1  7 2002 "A" 
1  8 2002 "A" 
1  9 2002 "B-"
1 10 2002 "B-"
1 11 2002 "B-"
1 12 2002 "B-"
end
In this example, there is only 1 firm ID , however, in my actual dataset, there will be thousands firm IDs. Some firms can be added into the list. For example, if firm ID 4 first appearance in the dataset is in 5/2003, then when I backfilling the data, there should be NO ratings for this firm before 5/2003.

Can you please suggest what I can do to create such dataset?

Thank you very much in advance.

Kind regards,
Mia