how to sort strings that differ by email addresses

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to sort strings that differ by email addresses

msherman
Dear List: I have a data file with email addresses (about 1000), for example
[hidden email]
[hidden email]
[hidden email]
[hidden email]
[hidden email]
[hidden email]
[hidden email].

I want to be able to sort the email addresses so that all of the emails from the same university are grouped together. Thus all of the eiu.edu will be bunched together, and the same would be true for all of the other universities.  Advice will be appreciated.

martin sherman

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: how to sort strings that differ by email addresses

ViAnn Beadle
Strip off the address using substring after finding the index of the @ and
save that as a separate variable. Upcase that variable so that unc.edu sorts
with UNC.educ. Then sort with that as the primary key:

STRING domain (a16).
COMPUTE domain=SUBSTRING(address,INDEX(address,'@')+1).
COMPUTE domain=UPCASE(domain).

Note that I'm not sure what the maximum width of a domain name can be here
so you might need to increase the string width for your result variable.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Martin Sherman
Sent: Tuesday, November 20, 2007 6:11 PM
To: [hidden email]
Subject: how to sort strings that differ by email addresses

Dear List: I have a data file with email addresses (about 1000), for example
[hidden email]
[hidden email]
[hidden email]
[hidden email]
[hidden email]
[hidden email]
[hidden email].

I want to be able to sort the email addresses so that all of the emails from
the same university are grouped together. Thus all of the eiu.edu will be
bunched together, and the same would be true for all of the other
universities.  Advice will be appreciated.

martin sherman

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: how to sort strings that differ by email addresses

Art Kendall-2
In reply to this post by msherman
My SPSS 16 has not arrived and my version 15 expired so I cannot test this.
string person (15) place(20).
compute atsign= index(emailaddress,"@").
compute howlong= length(rtrim(emailaddress, ' ')).
compute person = substr(emailaddress, 1,        atsign-1).
compute place  = substr(emailaddress, atsign+1, length-atsign).
sort cases by place person.

Art Kendall
Social Research Consultants

Martin Sherman wrote:

> Dear List: I have a data file with email addresses (about 1000), for example
> [hidden email]
> [hidden email]
> [hidden email]
> [hidden email]
> [hidden email]
> [hidden email]
> [hidden email].
>
> I want to be able to sort the email addresses so that all of the emails from the same university are grouped together. Thus all of the eiu.edu will be bunched together, and the same would be true for all of the other universities.  Advice will be appreciated.
>
> martin sherman
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD