Auto fill string ID variable

#1
Hey guys.

So I've been working on a project where I need to code a load of surveys. Each survey has (in groups of maybe 100) a specific group identifier and then a personal ID. Something like this:

N15-01
N15-02
N15-03
ect. for group one and then again for the next group:

N16-01
N16-02
ect.

What I would love to do (and this variable is string-coded, by the way) is a way to be able to do something like this

replace ID = N15-xx

where Stata understands, that it needs to start at 01 and end at maybe 87 but keeps the N15- first. Then I just need to do it to each group and not manually input the ID to each survey.
 
#2
assuming your group variabe (string: N15, N16....) is named "gr"

you can generate the xx number for each group
by gr: gen nb=_n

then tostring

tostring nb, replace

and generate your string ID

gen ID= gr + "-" + nb