|
Hi all-
I think I need the index function to read backwards. The issue is that I want the last 2 stems or all if there are 2 total. Example: ID Field 1 zzz.domain.com 2 somethingelse.org 3 anotherone.com 4 department.company.com 5 wer3.sdff.glrt.sdfgkljh.net Desired result: ID Field 1 domain.com 2 somethingelse.org 3 anotherone.com 4 company.com 5 sdfgkljh.net Can anyone help? Regards, Brian |
|
A quick and dirty solution:
data list free /id (f1) field (a30). begin data 1 zzz.domain.com 2 somethingelse.org 3 anotherone.com 4 department.company.com 5 wer3.sdff.glrt.sdfgkljh.net end data. string newfield (a30). compute #index1=rindex(field, "."). compute #index2=rindex(substr(field, 1, #index1-1), "."). compute newfield=substr(field, #index2+1). list. There's probably a more elegant solution. I tend to break up complex expressions into separate parts because it's easier for me to understand and debug. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Brian Moore Sent: Thursday, April 19, 2007 12:13 PM To: [hidden email] Subject: Index and web domains Hi all- I think I need the index function to read backwards. The issue is that I want the last 2 stems or all if there are 2 total. Example: ID Field 1 zzz.domain.com 2 somethingelse.org 3 anotherone.com 4 department.company.com 5 wer3.sdff.glrt.sdfgkljh.net Desired result: ID Field 1 domain.com 2 somethingelse.org 3 anotherone.com 4 company.com 5 sdfgkljh.net Can anyone help? Regards, Brian |
|
In reply to this post by Brian Moore-3
Works like a charm, thanks!
-----Original Message----- From: Oliver, Richard [mailto:[hidden email]] Sent: Thursday, April 19, 2007 10:34 AM To: Brian Moore; [hidden email] Subject: RE: Index and web domains A quick and dirty solution: data list free /id (f1) field (a30). begin data 1 zzz.domain.com 2 somethingelse.org 3 anotherone.com 4 department.company.com 5 wer3.sdff.glrt.sdfgkljh.net end data. string newfield (a30). compute #index1=rindex(field, "."). compute #index2=rindex(substr(field, 1, #index1-1), "."). compute newfield=substr(field, #index2+1). list. There's probably a more elegant solution. I tend to break up complex expressions into separate parts because it's easier for me to understand and debug. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Brian Moore Sent: Thursday, April 19, 2007 12:13 PM To: [hidden email] Subject: Index and web domains Hi all- I think I need the index function to read backwards. The issue is that I want the last 2 stems or all if there are 2 total. Example: ID Field 1 zzz.domain.com 2 somethingelse.org 3 anotherone.com 4 department.company.com 5 wer3.sdff.glrt.sdfgkljh.net Desired result: ID Field 1 domain.com 2 somethingelse.org 3 anotherone.com 4 company.com 5 sdfgkljh.net Can anyone help? Regards, Brian |
| Free forum by Nabble | Edit this page |
