I have a string variable that begins with the name of the month
followed by the date.
For example,
January 12/1/2010
March 4/3/1998
February 8/17/1990
.
.
.
What would be the simplest approach in SPSS to remove *only* the names
of the months from each cell? So, sticking with the example, I want it
to look like this:
12/1/2010
4/3/1998
8/17/1990
.
.
.
Any help would be appreciated!
Ryan
Hi Ryan. You can use CHAR.INDEX to find the position of the first
blank space in your string variable, and go from there. E.g.,
data list list / datestr(a25).
begin data
"January 12/1/2010"
"March 4/3/1998"
"February 8/17/1990"
end data.
string newstring(a10).
* Get position of first blank space.
compute #blankpos = char.index(datestr," ").
* Now use it to extract a substring from the original variable .
compute newstring = substr(datestr,#blankpos+1).
* Date and Time Wizard: newdate.
COMPUTE newdate=number(newstring, ADATE10).
VARIABLE LABELS newdate "".
VARIABLE LEVEL newdate (SCALE).
FORMATS newdate (ADATE10).
VARIABLE WIDTH newdate(10).
list.
HTH.
--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
Perfect! Thanks!