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:


Valid Literal Response





B12 4LT

BS35 3UW






BS35 3UW




BS35 3UW



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.

  1. Select View | Patterns from the Snap XMP Desktop menu to open the Patterns dialog. (Prior to build 12.10 this was on the Tailor menu.)
  2. Find and select the postcode uk pattern then click Clone CloneIcon.png to make a copy of it.
Patterns dialog showing the patterns that are supplied with Snap Desktop
  1. Name the new pattern UK Postal Area.
  2. In the Result box, clear the details then right click and select Component | area. {area} is shown in the Result box.
Pattern Properties dialog
  1. 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.
  2. 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.

  1. Select Variables VariablesIcon.png  from the Snap toolbar.
  2. Click New variable NewIcon.png to create a new variable.
  3. Enter the following values:
    1. Name PostalArea (or another meaningful name)
    2. Label Area
    3. Type Derived
    4. Response Single
  4. 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).
  5. Click Count Responses CountResponsesIcon.PNG  which displays the results in the Counts column.
Derived variable categorizing postcodes by postal area
  1. Click Save SaveIcon.png  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