spssforum.com from users, for users

SPSSforum.com is the largest free SPSS help resource worldwide.
On this SPSS forum you are sure to get an answer to your question!
Join the forum and let other SPSS users help you.

Join the SPSS users Group on LinkedIn
Join the SPSS Users Group
on LinkedIn
 
SPSSforum.com is a forum for SPSS users. Ask any question you like about SPSS or statistics.

It is currently Fri Sep 03, 2010 3:41 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Last part of string variable as basis for category variable
PostPosted: Thu Mar 12, 2009 1:05 pm 
Offline

Joined: Thu Mar 12, 2009 12:49 pm
Posts: 1
How can I create a numeric variable listing which domain people belong to, based on email adresses?

Hanna.Montana@firstplace.com ---> 1
Nimby@secondplace.com --- >2
Michael.Jackson@firstplace.com ---> 1
George.Washington@thirdplace.com ---> 3
Barack.Obama@secondplace.com ---> 2

...and so on.
I reckon I need to use some sort of wildcard, but this one doesn`t work:

DATASET ACTIVATE DataSet1.
DO IF (Adress = '*@thirdplace.com').
RECODE Adress (ELSE=3) INTO New_adr.
END IF.
EXECUTE.

Apparently wildcards only work at the beginning of strings?

Heidi


Top
 Profile  
 



 Post subject: Re: Last part of string variable as basis for category variable
PostPosted: Thu Mar 12, 2009 3:25 pm 
Offline
Moderator

Joined: Sun Dec 28, 2008 5:55 pm
Posts: 555
Location: Belo Horizonte, Brasil
You can use the TRANSFORM>RECODE INTO DIFFERENT VARIABLES - but first you must extract the domain only and recode base on the domain.

Under TRANSFORM>COMPUTE VARIABLES, create a new variable using the function
Code:
CHAR.INDEX(<e-mail variable name here>,'@')
to create a new variable with the position of the @ (11th character, 4th character...).
After that, use the function
Code:
CHAR.SUBSTR(<e-mail variable name here>,<character index variable name here>)
to extract the substring with the domain only (@blablabla, @12345, @kkkkk).

You can also change the CHAR.INDEX variable and add a +1 after the function, so the domain variable will start after the @ (blablabl, 12345, kkkkk).

_________________
BR

NOTE: "Please read the Posting Guidelines and always tell us your OS, the SPSS version and some information about your data!" - by statman.

Disponível em português (mas prefira inglês para que outros também entendam a solução).


Top
 Profile  
 
 Post subject: Re: Last part of string variable as basis for category variable
PostPosted: Wed Mar 18, 2009 9:40 pm 
Offline

Joined: Sat Jan 24, 2009 12:14 am
Posts: 4
Hi Heidi

Visit my website http://in2software.dk where you'll find a lot of free spss scripts, look for the script "Categorize".

This script will do what you are looking for.
You can categorize up to 20 variables in one swift action.


Top
 Profile  
 



Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL

This site is in no way connected with SPSS Inc. or any affiliate of SPPS Inc. The SPSS logo and products are owned by and copyrighted by SPSS Inc. The views expressed in the messages posted on this site are those of persons writing those comments and not necessarily those of the SPSSforum.com. SPSSforum.com does not vouch for the accuracy or truthfulness of any posted statement or opinion. The SPSSforum.com has, however, refrained from posting any item containing any statement known to be inaccurate, false or baseless.