Dear Statalists,

I am aware that I am creating an unconvential and unusual post, and apologize in advance if this forum is not the right place to find an answer to my problem. I am new to Stata, and have encountered a problem I've spent days on. I do not seem to be able to solve this issue, so any kind of help whatsoever would be truly appreciated.

I am currently working using two surveys: 1) the BHPS, and 2) the UKHLS. The BHPS runs from 1991 until 2008, and the UKHLS runs from 2009 until 2018. The two surveys are however harmonised, and can be therefore merged into just one big survey, running from 1991 directly unitl 2018.

However, in order to run regressions which make sense using the merged BHPS and UKHLS surveys, I need to use the proper weights. The official guide for the two surveys tells me that the specific weight I need to use in my analysis is called:
Code:
indin91_lw
The variable indin91_lw is only present in the UKHLS survey, and is created to harmonise the regressions which run from the BHPS years to the UKHLS years. I am however having a very hard time in understanding HOW to actually use the indin91_lw weight, especially since this weight is only present in the UKHLS survey years.

Looking online, I found the following guide: http://repository.essex.ac.uk/21094/...user-guide.pdf
At page 24, the guide provides a STATA example of how to use the indin91_lw weight, simulating a situation which is very similar to what I am experiencing.

My problem is the following: I cannot really understand how the weight is being used, and, most of all, I cannot make sense of the commands deployed to use the weight. My proposition is therefore to ask the forum if someone can explain what is actually going on in the example, of which I will post a photo below.
I will now proceed to describe the process of the code, and the passage I am having trouble with.

NOTE: along with the c_indresp_junk weight, the code will also deal with the psu and strata variables, where the psu variable is the primary sampling unit, and the strata variable is the sampling stratum from which the sample member was selected.
My concerns regarding indin91_lw extend to these two variables as well, although I will now only talk specifically about indin91_lw to simplify the post.

Basically, the code is appending file c_indresp_junk ( from the UKHLS survey) with file bq_indresp_junk (from the BHPS survey).
c_indresp_junk is a file containing information for a single year out of the UKHLS years (2009 - 2018), and bq_indresp_junk is a file containing information for a single year out of the BHPS years (1991 - 2008)
As we know, the weight variable indin91_lw only exists in the UKHLS survey, so in this case is only present in the c_indresp_junk file.

What I don't understand is what happens after the files have been appended:
The text says to "distribute unit's last wave longitudinal weight, psu and strata to all waves" (what does this even mean?), and then proceeds to use the following code
Code:
bys pidp: replace indin91_lw=indin91_lw[_N]
Can anybody at all explain me what this last line of code specifically does? Why is it used here? Does this code extend the indin91_lw variable to the bq_indresp_junk part of the dataset too?

I tried contacting the people in charge of the survey to ask them this question, but their "Contact us" page seems not to work.

Again, I know this is not a conventional post, nor is it a classic question, but I am very stuck on this issue and any help would be appreciated. Also, I am sorry I have had to upload a photo image, which is something which needs to be avoided on the forumArray