In Australia, all addresses have a postcode (i.e., a zip code), which is a three- or four digit number where the first digit identifies the state or territory of residence. You can create a custom JavaScript variable to use the postcodes (zip codes) to identify which state they belong to. This can also be done automatically for different scenarios using the Ready Made New Variables > Automatically Combine Categories > By Geography menu.
Technical details
The following code assumes the postcodes are stored as a text variable. If they are instead a Numeric variable already, change the var res line to:
var res = str;
Method
You will use the code below in the Expression of a JavaScript - Text variable, and then change the Structure > Nominal afterwards:
//replace postcodevariable with your postcode variable name in your data
var str = postcodevariable;
//convert the text postcodes to numeric values to use in the logic below var res = parseInt(str);
//setup if-else statements to use the post codes to classify into the states if ((res >= 200 && res <= 299) || (res >= 2600 && res <= 2619) || (res >= 2900 && res <=2920)) 'ACT'; else if ((res >= 1000 && res <= 2599) || (res >= 2620 && res <= 2899) || (res >= 2921 && res <=2999)) 'NSW'; else if ((res >= 3000 && res <= 3999) || (res >= 8000 && res <= 8099)) 'Victoria'; else if ((res >= 4000 && res <= 4999) || (res >= 9000 && res <= 9099)) 'Queensland'; else if (res >= 5000 && res <= 5999) 'SA'; else if (res >= 6000 && res <= 6999) 'WA'; else if (res >= 7000 && res <= 7999) 'TAS'; else if (res >= 800 && res <= 999) 8; 'NT'; else '';