PROC GEOCODE

Reply
Contributor
Posts: 39

PROC GEOCODE

How can I get the co-ordinates/geocode location down to suburbs/city and postcode.  I have used the ABS macro and it seems to calculate purely on postcode and not surburb/city...

Many thanks

G

Trusted Advisor
Posts: 1,270

Re: PROC GEOCODE

Hi G,


These files might help you... http://www.corra.com.au/australian-postcode-location-data/


Also for those that are wanting to use 3rd party shape files to build maps in SAS, Chris Hemedinger wrote a great blog post about this when he visited Oz a couple of years ago that you may also find useful, http://blogs.sas.com/content/sasdummy/2011/08/30/using-3rd-party-shape-files-to-build-map-charts-in-...


Cheers, Michelle

New Contributor MDR
New Contributor
Posts: 2

Re: PROC GEOCODE

Hi G.

Just a bit unclear to me precisely what you are after. Reply here or direct message me.

Cheers

m.

Super Contributor
Posts: 377

Re: PROC GEOCODE

Hi G,

I agree with MDR that your requirements are a bit "vague", so my reply may likewise be vague and not answer your question.

However, I have recently gone through an exercise using ABS data and geocoding.  So, perhaps the below will help you...or perhaps not.

1) ABS ESRI shapefiles: 

I don't find the ABS site particularly user friendly for finding what I needed, but eventually I stumbled upon these three links which I've saved:

1259.0.30.001 - Australian Standard Geographical Classification (ASGC) Digital Boundaries, Australia...

1270.0.55.001 - Australian Statistical Geography Standard (ASGS): Volume 1 - Main Structure and Grea...

1270.0.55.003 - Australian Statistical Geography Standard (ASGS): Volume 3 - Non ABS Structures, Jul...

So I would encourage you to familiarize yourself with what's available on these links.

You may also want to skim the below links and see what else looks of interest:

http://www.abs.gov.au/AUSSTATS/abs@.nsf/viewcontent?readform&view=productsbyCatalogue&Action=expandw...

http://www.abs.gov.au/AUSSTATS/abs@.nsf/ViewContent?readform&view=productsbyCatalogue&Action=Expand&...

The files I found most useful were on the 1270.0.55.001 page (2nd link) for Statistical Areas and 1270.0.55.003 (3rd link) for postcode data.

Search these pages for "ESRI Shapefile Format", download the zips, import into SAS, and see which meets your needs.  Importing into SAS and reviewing the data was the only thing that worked for me and enabled me to determine which files met my needs.

2) Mapping Postcode to ABS Statistical Areas:

This is my understanding; it's just conjecture, so someone please correct me if I'm wrong...

The ABS determine "statistical areas", while Australia Post determine postcodes.  Since these are two separate government departments, they of course don't talk to each other Smiley Wink

This link contains files mapping postcodes to statistical areas:

1270.0.55.006 - Australian Statistical Geography Standard (ASGS): Correspondences, July 2011

Scroll to the bottom of the file and download the "Postcode 2011 to ..." zip files.  These are Excel files mapping postcodes to SA's.  The worksheet of interest is Table 3, which maps postcode to SA's, with varying degrees of accuracy.  There is a Ratio/Percentage column which indicates how much of the postcode is contained in an SA, since a postcode can overlap a number of SA's.

For my purpose, my data already contained postcode, and we chose the "best fit" for postcode to SA mapping.  Because of this, we could not map below SA3 (SA1-SA4 go from most granular/smallest areas to least granular/larger areas).  An alternative would be to use the ratio as a weighting factor, assuming population distribution consistent with the ratio.

This established the hierarchy for our geocoding/mapping:  State --> Greater Capital City --> SA4 --> SA3 --> Postcode

3) %reduce_pixel macro:

The ABS ESRI shapefiles are "huge", and can be effectively reduced without affecting mapping clarity.  Use the %reduce_pixel macro here, rather than directly calling PROC GREDUCE:  SAS Maps Online.  I have a modified version of the macro I can send if you wish (hint:  fiddle with the X/Y derivations to increase/decrease desired data points in the output dataset).

Make sure you click that link above, as well as all the sidebar links.  In particular:  SAS Maps Online, search on "Australia".

4) Miscellaneous:

Example code below, submitted without further comment.  You'd need some of the utility macros to run it, but hopefully you can see what the code is doing.

Apologies for the length of this post, but I hope some of it proves useful to your issue.   Regards, Scott.

*** IMPORT ESRI DATA *** ;

options validvarname=any;

options mprint;

* location of ESRI Shapefiles ;

%let esri_location = C:\Foo\Bar\mapinfo;

%macro code;

proc mapimport out=workspde.&word._raw datafile="&esri_location\&word..shp";

run;

%mend;

%loop(

STE_2011_AUST

GCCSA_2011_AUST

SA4_2011_AUST

SA3_2011_AUST

SA2_2011_AUST

SA1_2011_AUST

POA_2011_AUST

)

*** TRANSFORM ESRI DATA *** ;

* Define these in reverse order, from most detailed (SA1) to least detailed (State), for easier code maintenance ;

* Uncomment the "else" clause in the below code to see the effect of deleting missing X and Y data points ;

* SA1 ;

%let data=map_au_sa1;

data workspde.&data._missing workspde.&data;

format segment stateId stateName gccsaId gccsaName sa4Id sa4Name sa3Id sa3Name sa2Id sa25digId sa2Name sa1Id sa17digId long lat x y sqkm;

keep   segment stateId stateName gccsaId gccsaName sa4Id sa4Name sa3Id sa3Name sa2Id sa25digId sa2Name sa1Id sa17digId long lat x y sqkm;

set workspde.sa1_2011_aust_raw;

segment       = segment;

stateId       = ste_code11;

stateName     = ste_name11;

gccsaId       = gcc_code11;

gccsaName     = gcc_name11;

sa4Id         = sa4_code11;

sa4Name       = sa4_name11;

sa3Id         = sa3_code11;

sa3Name       = sa3_name11;

sa2Id         = sa2_main11;

sa25digId     = sa2_5dig11;

sa2Name       = sa2_name11;

sa1Id         = sa1_main11;

sa17digId     = sa1_7dig11;

long          = x;

lat           = y;

sqkm          = albers_sqm / (1000**2);

format sqkm comma18.2;

if missing(x) or missing(y) then

output workspde.&data._missing;

/* else */

output workspde.&data;

run;

* SA2 ;

%let data=map_au_sa2;

data workspde.&data._missing workspde.&data;

format segment stateId stateName gccsaId gccsaName sa4Id sa4Name sa3Id sa3Name sa2Id sa25digId sa2Name long lat x y sqkm;

keep   segment stateId stateName gccsaId gccsaName sa4Id sa4Name sa3Id sa3Name sa2Id sa25digId sa2Name long lat x y sqkm;

set workspde.sa2_2011_aust_raw;

segment       = segment;

stateId       = ste_code11;

stateName     = ste_name11;

gccsaId       = gcc_code11;

gccsaName     = gcc_name11;

sa4Id         = sa4_code11;

sa4Name       = sa4_name11;

sa3Id         = sa3_code11;

sa3Name       = sa3_name11;

sa2Id         = sa2_main11;

sa25digId     = sa2_5dig11;

sa2Name       = sa2_name11;

long          = x;

lat           = y;

sqkm          = albers_sqm / (1000**2);

format sqkm comma18.2;

if missing(x) or missing(y) then

output workspde.&data._missing;

/* else */

output workspde.&data;

run;

* etc, etc ;

*** MAP POSTCODE TO SA's VIA FORMATS *** ;

* Mapping Postcode to SA1 or SA2 is "messy" due to the low ratio values ;

* Map Postcode to SA3 using the ABS Postcode to SA3 Excel mapping file. ;

* Map SA3 to higher levels using the SA3 ESRI file with the embedded hierarchy. ;

* Get best fit list of postcodes from the ABS Postcode to SA3 Excel mapping file. ;

proc sort data=meta.map_abs_postcode_to_sa3 out=workspde.formats nodupkey;

by postcode;

where bestfit=1;

run;

* Get the de-duped SA3 -> SA4 -> GCCSA -> State hierarchy from SA3 ESRI file. ;

proc sort data=workspde.map_au_sa3 (keep=sa3: sa4: gccsa: stateSmiley Happy out=workspde.ids nodupkey;

by _all_;

run;

* Postcode --> SA3 Formats ;

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.formats

,NAME=PostcodeToSA3Id

,TYPE=num_format

,START=postcode

,LABEL=sa3Id

,OTHER=_MISSING_

,DEDUP=Y

)

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.formats

,NAME=PostcodeToSA3Name

,TYPE=num_format

,START=postcode

,LABEL=sa3Name

,OTHER=_MISSING_

,DEDUP=Y

)

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=SA3IdToSA3name

,TYPE=chr_format

,START=sa3Id

,LABEL=sa3Name

,OTHER=_MISSING_

,DEDUP=Y

)

* SA3 to SA4 Formats ;

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=SA3IdToSA4Id    

,TYPE=chr_format

,START=sa3Id   

,LABEL=sa4Id

,OTHER=_MISSING_

,DEDUP=Y

)

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=SA4IdToSA4Name      

,TYPE=chr_format

,START=sa4Id   

,LABEL=sa4Name

,OTHER=_MISSING_

,DEDUP=Y

)

* SA3 to GCCSA Formats ;

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=SA3IdToGCCSAId    

,TYPE=chr_format

,START=sa3Id   

,LABEL=gccsaId

,OTHER=_MISSING_

,DEDUP=Y

)

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=GCCSAIdToGCCSAName      

,TYPE=chr_format

,START=gccsaId   

,LABEL=gccsaName

,OTHER=_MISSING_

,DEDUP=Y

)

* SA3 to State Formats ;

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=SA3IdToStateId    

,TYPE=chr_format

,START=sa3Id   

,LABEL=stateId

,OTHER=_MISSING_

,DEDUP=Y

)

%create_format(

LIB=LIBRARY

,CAT=FORMATS

,DATA=workspde.ids

,NAME=stateIdToStateName      

,TYPE=chr_format

,START=stateId   

,LABEL=stateName

,OTHER=_MISSING_

,DEDUP=Y

)

Contributor
Posts: 34

Re: PROC GEOCODE

"The ABS determine "statistical areas", while Australia Post determine postcodes.  Since these are two separate government departments, they of course don't talk to each other "

Australian postcodes are primarily designed for delivering mail, nothing more. Auspost used to publish maps of postcodes which were quite useful particularly outside urban areas (last published 1993). One thing you need to note when using the ABS concordance files is that ABS postcode is not necessarily true postcode, its a best estimate using the ABS smallest geographical unit, previously Collectors District, and now Mesh Block, in fact if you look at the old CD based boundaries for postcode and the new MB based ones they appear quite different and neither match true postcode boundaries. One other point about postcodes, they are not necessarily contiguous eg 4751 near Mackay.

R

New Contributor MDR
New Contributor
Posts: 2

Re: PROC GEOCODE

Yes indeed, there are many tricks and traps when using postcodes and "postal areas", which are the ABS approximation of postcodes. And I think that they are built from whole SA1s rather than meshblocks.

Contributor
Posts: 34

Re: PROC GEOCODE

You are quite correct, postal areas are constructed from SA1.

R

Super Contributor
Posts: 377

Re: PROC GEOCODE

I found this in my collection of downloaded SGF papers.  See the ReadMe file in the zip for more details.  I hope it's useful!

Contributor
Posts: 39

Re: PROC GEOCODE

Hi Everybody,

Apologies for not replying sooner.  Thank you for all your replies, I will review the SAS Code and suggestions above. My initial aim was to try and identify customer locations similar what can be done in the UK, i.e. down to house level by postcode.

Many thanks

G.

Ask a Question
Discussion stats
  • 8 replies
  • 905 views
  • 8 likes
  • 5 in conversation