{"id":4991,"date":"2012-10-23T15:08:04","date_gmt":"2012-10-23T15:08:04","guid":{"rendered":"https:\/\/www.snapsurveys.com\/support-snap11\/?page_id=4991"},"modified":"2018-10-04T15:43:22","modified_gmt":"2018-10-04T14:43:22","slug":"patterns-categorise-postcodes-postal-area","status":"publish","type":"page","link":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/","title":{"rendered":"Using patterns to categorise postcodes in to postal area"},"content":{"rendered":"<p>In last months worksheet we applied a pattern to validate or transform a quantity response during an interview. We will now look at applying a pattern at analysis stage. This particular example uses a derived variable in conjunction with a pattern to extract the postal area part from a full UK postcode.<\/p>\n<p>This example uses the Snap WebHost edition of the Crocodile survey which is provided with Snap.<\/p>\n<p><strong>In this example, we will use a literal response, open ended question. This question has a source pattern of \u2018Postcode UK\u2019 applied. This pattern is pre-loaded within Snap and may be used to validate replies to literal response questions representing UK postcodes.<\/strong><\/p>\n<p>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:<\/p>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<th>Component<\/th>\n<th>Acceptable Literal Response<\/th>\n<th>Example<\/th>\n<\/tr>\n<tr>\n<td><strong>Area<\/strong><\/td>\n<td>{letter}<br \/>\n{letter}{letter}<\/td>\n<td><strong>B<\/strong>12 4LT BS35 3UW<\/td>\n<\/tr>\n<tr>\n<td><strong>District<\/strong><\/td>\n<td>{digit}<br \/>\n{digit}{digit}<br \/>\n{digit}{letter}<\/td>\n<td>BA<strong>3<\/strong> 4HT<br \/>\nBS<strong>35 <\/strong>3UW<br \/>\nSW<strong>1Y <\/strong>4RF<\/td>\n<\/tr>\n<tr>\n<td><strong>Sector<\/strong><\/td>\n<td>{digit}<\/td>\n<td>BS35 <strong>3<\/strong>UW<\/td>\n<\/tr>\n<tr>\n<td><strong>Unit<\/strong><\/td>\n<td>{letter}{letter}<\/td>\n<td>BS35 3<strong>UW<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Step by step<\/h3>\n<div>\n<h3>Step 1<\/h3>\n<p><strong>The first step is to create a new pattern that will extract postcode area from a full UK postcode.<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24825\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image020.png\" alt=\"Enter zip \/ postcode\" width=\"220\" height=\"51\" srcset=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image020.png 220w, https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image020-150x35.png 150w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24826\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image022.png\" alt=\"Variable Properties | Postcode uk\" width=\"220\" height=\"283\" srcset=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image022.png 220w, https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image022-150x193.png 150w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/p>\n<\/div>\n<ol>\n<li>\u00a0Select<strong> Tailor<\/strong> | <strong>Patterns<\/strong> from the main Snap toolbar.\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24830\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/patterns_win.png\" alt=\"Patterns window\" width=\"443\" height=\"420\" srcset=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/patterns_win.png 443w, https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/patterns_win-150x142.png 150w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/p>\n<\/div>\n<\/li>\n<li>Scroll down to the \u2018Postcode UK\u2019 pattern and highlight it.<\/li>\n<li>Click <strong>[Clone]<\/strong> to make a copy of it.<\/li>\n<li>Name the new pattern as <strong>UK Postal Area.<\/strong><\/li>\n<li>Click in the <strong>Result<\/strong> box and clear the details. Right click, from the menu, select <strong>Component<\/strong> and then <strong>area,\u00a0<\/strong><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24833\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/area.png\" alt=\"{area}\" width=\"46\" height=\"15\" \/>\u00a0will then appear in the Result box.\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24827\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image030.png\" alt=\"Pattern Properties | Result | select Component then area\" width=\"220\" height=\"234\" srcset=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image030.png 220w, https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image030-150x160.png 150w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/p>\n<\/div>\n<\/li>\n<li>To test the pattern, click the <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24831\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/test.gif\" alt=\"Test...\" width=\"74\" height=\"23\" \/>\u00a0button and type a postcode in the text box. If set up correctly, the result box should display just the area component of the postcode.<\/li>\n<li>Click <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24630\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/01\/226.png\" alt=\"OK button\" width=\"75\" height=\"23\" \/>\u00a0to exit the pattern test and then click <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24630\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/01\/226.png\" alt=\"OK button\" width=\"75\" height=\"23\" \/>\u00a0again to save your pattern.<\/li>\n<\/ol>\n<h3>Step 2<\/h3>\n<p><strong>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 above.<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24828\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image032.png\" alt=\"Pattern Match\" width=\"220\" height=\"95\" srcset=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image032.png 220w, https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image032-150x65.png 150w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/p>\n<ol>\n<li>Select the Variables icon <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22698\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2016\/07\/VariablesButton.png\" alt=\"VariablesButton\" width=\"24\" height=\"22\" \/>\u00a0from the main Snap toolbar.<\/li>\n<li>Click the <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22699\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2016\/07\/Plus.png\" alt=\"plus | add\" width=\"24\" height=\"22\" \/>\u00a0icon to create a new variable. Make a note of the name and enter \u2018Area\u2019 as the Label<\/li>\n<li>The <strong>Type<\/strong> will be <strong>Derived<\/strong> and the <strong>Response<\/strong> will be <strong>Single<\/strong>.<\/li>\n<li>In the bottom half of the screen, double click in the Label column, and add a code label of <strong>Birmingham<\/strong>.<\/li>\n<li>Use the Tab key to move across to the Values column.<\/li>\n<li>Type <strong>Q11 as UK Postal Area ==&#8221;B&#8221;<\/strong>\n<div>Birmingham postcodes contain the letter B as the area component, e.g. <strong>B<\/strong>12 4LT. A value of <strong>Q11 as UK Postal Area =&#8221;B&#8221;<\/strong> will count any postal area containing <strong>B<\/strong> e.g. <strong>BS<\/strong>35 3UW which is a Bristol postcode. Therefore it is necessary to search for an exact match using = =.<\/div>\n<\/li>\n<li>Tab again for the next code label which will be <strong>Bristol<\/strong>.<br \/>\nThe value will be <strong>Q11 as UK Postal Area =&#8221;BS&#8221;<\/strong><\/li>\n<li>Tab again for the next code label which will be <strong>Reading<\/strong>.<br \/>\nThe value will be<strong> Q11 as UK Postal Area =&#8221;RG&#8221;<\/strong><\/li>\n<li>To run the variable, click <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24823\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/count-icon.gif\" alt=\"Count icon\" width=\"26\" height=\"23\" \/>\u00a0which will display the results in the Counts column.\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24829\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image034.png\" alt=\"Variable Details\" width=\"220\" height=\"187\" srcset=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image034.png 220w, https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2017\/02\/image034-150x128.png 150w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/p>\n<\/div>\n<\/li>\n<li>Click <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22703\" src=\"https:\/\/www.snapsurveys.com\/support-snap11\/wp-content\/uploads\/2016\/07\/Save.png\" alt=\"Save\" width=\"24\" height=\"22\" \/>\u00a0to save the derived variable.You can then use this new variable to create tables and charts.<\/li>\n<\/ol>\n<p>If there is a topic you would like a worksheet on, email to <a title=\"\" href=\"mailto:snapideas@snapsurveys.com\" target=\"_self\">snapideas@snapsurveys.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><a class=\"ninja_pages_read_more\"  href=\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/\"><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"parent":43,"menu_order":129,"comment_status":"open","ping_status":"closed","template":"page-templates\/child-page.php","meta":{"_acf_changed":false,"footnotes":""},"class_list":{"0":"post-4991","1":"page","2":"type-page","3":"status-publish","5":"search_category-support-hub"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using patterns to categorise postcodes in to postal area - Snap Surveys<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using patterns to categorise postcodes in to postal area - Snap Surveys\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/\" \/>\n<meta property=\"og:site_name\" content=\"Snap Surveys\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SnapSurveys\" \/>\n<meta property=\"article:modified_time\" content=\"2018-10-04T14:43:22+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@snapsurveys\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/\",\"name\":\"Using patterns to categorise postcodes in to postal area - Snap Surveys\",\"isPartOf\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snap11\/#website\"},\"datePublished\":\"2012-10-23T15:08:04+00:00\",\"dateModified\":\"2018-10-04T14:43:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.snapsurveys.com\/support-snap11\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Worksheets\",\"item\":\"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using patterns to categorise postcodes in to postal area\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snap11\/#website\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snap11\/\",\"name\":\"Snap Surveys\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.snapsurveys.com\/support-snap11\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using patterns to categorise postcodes in to postal area - Snap Surveys","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_GB","og_type":"article","og_title":"Using patterns to categorise postcodes in to postal area - Snap Surveys","og_url":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/","og_site_name":"Snap Surveys","article_publisher":"https:\/\/www.facebook.com\/SnapSurveys","article_modified_time":"2018-10-04T14:43:22+00:00","twitter_card":"summary_large_image","twitter_site":"@snapsurveys","twitter_misc":{"Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/","url":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/","name":"Using patterns to categorise postcodes in to postal area - Snap Surveys","isPartOf":{"@id":"https:\/\/www.snapsurveys.com\/support-snap11\/#website"},"datePublished":"2012-10-23T15:08:04+00:00","dateModified":"2018-10-04T14:43:22+00:00","breadcrumb":{"@id":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/patterns-categorise-postcodes-postal-area\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.snapsurveys.com\/support-snap11\/"},{"@type":"ListItem","position":2,"name":"Worksheets","item":"https:\/\/www.snapsurveys.com\/support-snap11\/worksheets\/"},{"@type":"ListItem","position":3,"name":"Using patterns to categorise postcodes in to postal area"}]},{"@type":"WebSite","@id":"https:\/\/www.snapsurveys.com\/support-snap11\/#website","url":"https:\/\/www.snapsurveys.com\/support-snap11\/","name":"Snap Surveys","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.snapsurveys.com\/support-snap11\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"}]}},"_links":{"self":[{"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/pages\/4991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/comments?post=4991"}],"version-history":[{"count":9,"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/pages\/4991\/revisions"}],"predecessor-version":[{"id":26199,"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/pages\/4991\/revisions\/26199"}],"up":[{"embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/pages\/43"}],"wp:attachment":[{"href":"https:\/\/www.snapsurveys.com\/support-snap11\/wp-json\/wp\/v2\/media?parent=4991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}