Hello,
I have a dataset from the UK land registry in which I have thousands of housing transactions. I have the postcode variable for each house and have created a postcode area variable. I now need to create two new variables: postcode district and postcode sector.
Just to be clear, UK postcodes take this form: "The first, one or two letters indicate the postcode area, followed by one or two digits signifying a district within that area. This is followed by a space and then a number denoting a sector within said district, and finally by two letters which are allocated to streets or sides of a street."
Using: generate area = substr(postcode, 1, (2 - inrange(substr(postcode, 2, 1), "0", "9"))). I have managed to form a postcode area variable e.g. where "SE" and "E" are formed from the likes of "SE25 6AS" and "E7 9NB" respectively.
I now must create two more variables from the original postcode variable in order to form more specific postcode sector and postcode district variables (e.g. from "SE25 6AS", I would need to obtain variables which display this as "SE25" and "SE25 6") and do not really know how to go about doing this as UK postcodes vary in length from 5 to 7 characters.
Thank you
Related Posts with Using "substr" to split UK postcodes into areas and sectors
New on SSC: CONJOINT: a module to analyse and visualise conjoint (factorial) experimentsWith thanks as always to Kit Baum, a new package called -conjoint- is now available on the SCC. con…
Generalized DDDGood day, all of you. My name is Franco Vegas and I'm currently doing my thesis on the effect on av…
stata panel dataI am going to measure the standarized mean value of 4 environmental indicators (AA, BB, CC and DD). …
Seek help for concentration curveDear Sir/Madam, colleagues, I tried to plot a concentration curve with the following commend from s…
Problems creating a single variable that represents the different conditions of my experimentHi all, For my Master thesis, I used Qualtrics for an online experiment and within this experiment …
Subscribe to:
Post Comments (Atom)
0 Response to Using "substr" to split UK postcodes into areas and sectors
Post a Comment