Using patterns to categorise postcodes by postal area
This tutorial shows how to apply a pattern at the analysis stage. This particular example uses a derived variable in conjunction with a pattern to extract the postal area from a full UK postcode. The postcode uk pattern is supplied with Snap XMP Desktop and may be used to validate replies to literal response questions representing UK postcodes.
The UK postcode standard is made up of four components; Area, District, Sector and Unit. Each component is then broken down to accept a particular literal response as detailed in the table below:
Component | Valid Literal Response | Example |
Area | {letter} {letter}{letter} | B12 4LT BS35 3UW |
District | {digit} {digit}{digit} {digit}{letter} | BA3 4HT BS35 3UW SW1Y 4RF |
Sector | {digit | BS35 3UW |
Unit | {letter}{letter} | BS35 3UW |
Step 1: Creating a new pattern to extract the postcode area
The first step is to create a new pattern that will extract postcode area from a full UK postcode.
- Select View | Patterns from the Snap XMP Desktop menu to open the Patterns dialog.
- Find and select the postcode uk pattern then click Clone to make a copy of it.
- Name the new pattern UK Postal Area.
- In the Result box, clear the details then right click and select Component | area. {area} is shown in the Result box.
- To test the pattern, click Test and type a postcode in the text box. If set up correctly, the result box should display just the area component of the postcode.
- Click OK to exit the pattern test and then click OK again to save your pattern.
Step 2: Creating a derived variable to use the new pattern
The second step is to create a derived variable that can be used in conjunction with the UK Postal Area pattern that you have created.
- Select Variables from the Snap toolbar.
- Click New variable to create a new variable.
- Enter the following values:
- Name PostalArea (or another meaningful name)
- Label Area
- Type Derived
- Response Single
- In the code list you can identify the postcode areas that you want to use in the analysis stage. In the example, the analysis looks at the postal areas for Birmingham (B), Bristol (BS) and Reading (RG).
- Click Count Responses which displays the results in the Counts column.
- Click Save to save the derived variable. You can then use this new variable to create tables and charts.
If there is a topic you would like a tutorial on, email to snapideas@snapsurveys.com