The DHS Program User Forum - RDF feed
https://userforum.dhsprogram.com/index.php
Generating ID variable
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=14878&th=7022#msg_14878
I am trying to make a new cluster number based on the cluster number available in the data set for merging with geographical data, but so far without any luck. The new id that I'd like to make should be 8 digits where 2 are string and others are numeric, where 3 digit available in the data set. As for example, i need to replace cluster number 001 with BD2014001.
Any help would be appreciate. ]]>sumonrupop2018-05-10T23:49:34-00:00Re: Generating ID variable
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=14882&th=7022#msg_14882
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.
]]>Bridgette-DHS2018-05-11T13:06:09-00:00Re: Generating ID variable
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=14883&th=7022#msg_14883
sumonrupop2018-05-11T14:00:23-00:00