The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Generating ID variable
Re: Generating ID variable [message #14882 is a reply to message #14878] Fri, 11 May 2018 09:06 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3051
Registered: February 2013
Senior Member

Following is a response from Senior DHS Stata Specialist, Tom Pullum:

The only complication with this is that you need to insert leading zeroes when the cluster code is less than 100. The following lines will do this within the PR file.

gen str3 strhv001=string(hv001)
replace strhv001="0"+string(hv001) if hv001<100
replace strhv001="00"+string(hv001) if hv001<10
replace strhv001="BD2014"+strhv001

The constructed variable will automatically reset to 9 columns, even though it started with 3.

 
Read Message
Read Message
Read Message
Previous Topic: MERGING THREE DHS DATASETS
Next Topic: Merging IR and KR with PR - no unique identifiers (for particular countries only)
Goto Forum:
  


Current Time: Tue May 7 13:41:17 Coordinated Universal Time 2024