Skip to content

Instantly share code, notes, and snippets.

@DataTwirling
Created October 30, 2010 14:01
Show Gist options
  • Save DataTwirling/655325 to your computer and use it in GitHub Desktop.
Save DataTwirling/655325 to your computer and use it in GitHub Desktop.
*###############################################################.
* Extract email domain from a field within SPSS data file.
* BLOG: http://datatwirling.wordpress.com/.
* TWITTER: @SPSSFanBoy
* DATE: October 2010
* VERSION: SPSS v19.0.0
*###############################################################.
* Let's create some fake data.
DATA LIST FREE /email_field (A100).
DATASET NAME temp.email.
BEGIN DATA
jermaine@conchords.com
''
brett@conchords.edu
homer@simpson.net.org
antoinedodson
END DATA.
* Set the field to a string with a length of 100 charactsers.
* Most likely way too many; skips '@' sign.
DATASET ACTIVATE temp.email.
STRING domain (A100).
COMPUTE domain=CHAR.SUBSTR(email_field,CHAR.INDEX(email_field,'@')+1).
EXECUTE.
* Look at distribution by domain, ORDER BY count DESC.
FREQ domain /FORMAT=DFREQ.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment