f



Deleting Characters from a String Variable

Hello:

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

0
Ryan
3/24/2010 8:34:18 PM
comp.soft-sys.stat.spss 5679 articles. 0 followers. Post Follow

16 Replies
4129 Views

Similar Articles

[PageSpeed] 36

On Mar 24, 4:34=A0pm, Ryan <ryan.andrew.bl...@gmail.com> wrote:
> Hello:
>
> 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 =3D char.index(datestr," ").

* Now use it to extract a substring from the original variable .

compute newstring =3D substr(datestr,#blankpos+1).

* Date and Time Wizard: newdate.
COMPUTE newdate=3Dnumber(newstring, ADATE10).
VARIABLE LABELS newdate "".
VARIABLE LEVEL  newdate (SCALE).
FORMATS newdate (ADATE10).
VARIABLE WIDTH  newdate(10).

list.

HTH.

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0
Bruce
3/24/2010 8:54:09 PM
On Mar 24, 4:54=A0pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
> On Mar 24, 4:34=A0pm, Ryan <ryan.andrew.bl...@gmail.com> wrote:
>
>
>
>
>
> > Hello:
>
> > 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. =A0You can use CHAR.INDEX to find the position of the first
> blank space in your string variable, and go from there. =A0E.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 =3D char.index(datestr," ").
>
> * Now use it to extract a substring from the original variable .
>
> compute newstring =3D substr(datestr,#blankpos+1).
>
> * Date and Time Wizard: newdate.
> COMPUTE newdate=3Dnumber(newstring, ADATE10).
> VARIABLE LABELS newdate "".
> VARIABLE LEVEL =A0newdate (SCALE).
> FORMATS newdate (ADATE10).
> VARIABLE WIDTH =A0newdate(10).
>
> list.
>
> HTH.
>
> --
> Bruce Weaver
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home
> "When all else fails, RTFM."- Hide quoted text -
>
> - Show quoted text -

Perfect! Thanks!
0
Ryan
3/24/2010 9:04:32 PM
On Wednesday, March 24, 2010 2:04:32 PM UTC-7, R wrote:
> On Mar 24, 4:54=A0pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
> > On Mar 24, 4:34=A0pm, Ryan <ryan.andrew.bl...@gmail.com> wrote:
> >
> >
> >
> >
> >
> > > Hello:
> >
> > > 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 name=
s
> > > of the months from each cell? So, sticking with the example, I want i=
t
> > > to look like this:
> >
> > > 12/1/2010
> > > 4/3/1998
> > > 8/17/1990
> > > .
> > > .
> > > .
> >
> > > Any help would be appreciated!
> >
> > > Ryan
> >
> > Hi Ryan. =A0You can use CHAR.INDEX to find the position of the first
> > blank space in your string variable, and go from there. =A0E.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 =3D char.index(datestr," ").
> >
> > * Now use it to extract a substring from the original variable .
> >
> > compute newstring =3D substr(datestr,#blankpos+1).
> >
> > * Date and Time Wizard: newdate.
> > COMPUTE newdate=3Dnumber(newstring, ADATE10).
> > VARIABLE LABELS newdate "".
> > VARIABLE LEVEL =A0newdate (SCALE).
> > FORMATS newdate (ADATE10).
> > VARIABLE WIDTH =A0newdate(10).
> >
> > list.
> >
> > HTH.
> >
> > --
> > Bruce Weaver
> > bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home
> > "When all else fails, RTFM."- Hide quoted text -
> >
> > - Show quoted text -
>=20
> Perfect! Thanks!

This is interesting, but what if there is no space separating the months an=
d dates? How can you separate those into two columns?

Thanks
0
ross
12/13/2013 12:16:05 AM
On Thursday, December 12, 2013 7:16:05 PM UTC-5, ross.d...@gmail.com wrote:
> On Wednesday, March 24, 2010 2:04:32 PM UTC-7, R wrote:
>=20
> > On Mar 24, 4:54=A0pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
>=20
> > > On Mar 24, 4:34=A0pm, Ryan <ryan.andrew.bl...@gmail.com> wrote:
>=20
> > >
>=20
> > >
>=20
> > >
>=20
> > >
>=20
> > >
>=20
> > > > Hello:
>=20
> > >
>=20
> > > > I have a string variable that begins with the name of the month
>=20
> > > > followed by the date.
>=20
> > >
>=20
> > > > For example,
>=20
> > >
>=20
> > > > January 12/1/2010
>=20
> > > > March 4/3/1998
>=20
> > > > February 8/17/1990
>=20
> > > > .
>=20
> > > > .
>=20
> > > > .
>=20
> > >
>=20
> > > > What would be the simplest approach in SPSS to remove *only* the na=
mes
>=20
> > > > of the months from each cell? So, sticking with the example, I want=
 it
>=20
> > > > to look like this:
>=20
> > >
>=20
> > > > 12/1/2010
>=20
> > > > 4/3/1998
>=20
> > > > 8/17/1990
>=20
> > > > .
>=20
> > > > .
>=20
> > > > .
>=20
> > >
>=20
> > > > Any help would be appreciated!
>=20
> > >
>=20
> > > > Ryan
>=20
> > >
>=20
> > > Hi Ryan. =A0You can use CHAR.INDEX to find the position of the first
>=20
> > > blank space in your string variable, and go from there. =A0E.g.,
>=20
> > >
>=20
> > > data list list / datestr(a25).
>=20
> > > begin data
>=20
> > > "January 12/1/2010"
>=20
> > > "March 4/3/1998"
>=20
> > > "February 8/17/1990"
>=20
> > > end data.
>=20
> > >
>=20
> > > string newstring(a10).
>=20
> > > * Get position of first blank space.
>=20
> > > compute #blankpos =3D char.index(datestr," ").
>=20
> > >
>=20
> > > * Now use it to extract a substring from the original variable .
>=20
> > >
>=20
> > > compute newstring =3D substr(datestr,#blankpos+1).
>=20
> > >
>=20
> > > * Date and Time Wizard: newdate.
>=20
> > > COMPUTE newdate=3Dnumber(newstring, ADATE10).
>=20
> > > VARIABLE LABELS newdate "".
>=20
> > > VARIABLE LEVEL =A0newdate (SCALE).
>=20
> > > FORMATS newdate (ADATE10).
>=20
> > > VARIABLE WIDTH =A0newdate(10).
>=20
> > >
>=20
> > > list.
>=20
> > >
>=20
> > > HTH.
>=20
> > >
>=20
> > > --
>=20
> > > Bruce Weaver
>=20
> > > bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Ho=
me
>=20
> > > "When all else fails, RTFM."- Hide quoted text -
>=20
> > >
>=20
> > > - Show quoted text -
>=20
> >=20
>=20
> > Perfect! Thanks!
>=20
>=20
>=20
> This is interesting, but what if there is no space separating the months =
and dates? How can you separate those into two columns?
>=20
>=20
>=20
> Thanks
maybe
COMPUTE #1=3DCHAR.INDEX(var,"0123456789",1)-1.
COMPUTE #2=3DCHAR.INDEX(var," ").
verify that #1 and #2 match?  Parse on #1 if not or maybe just use #1 and d=
on't bother with #2 if you don't know that you have odd data.

0
David
12/13/2013 8:48:22 AM
data list list / datestr(a25).
begin data
"January 12/1/2010"
"March 4/3/1998"
"February 8/17/1990"
"January12/1/2010"
"March4/3/1998"
"February8/17/1990"
end data.
string workstring (a25).
compute workstring ="".
do repeat index= 1 to 25.
    do if  not range(substr(datestr,index,1), "A","Z","a", "z").
       compute workstring = 
concat(rtrim(workstring),substr(datestr,index,1)).
    end if.
end repeat.
numeric mydate(adate10).
compute mydate = number(workstring,adate10).
list.


Art Kendall
Social Research Consultants

On 12/12/2013 7:16 PM, ross.dammann@gmail.com wrote:
> On Wednesday, March 24, 2010 2:04:32 PM UTC-7, R wrote:
>> On Mar 24, 4:54 pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
>>> On Mar 24, 4:34 pm, Ryan <ryan.andrew.bl...@gmail.com> wrote:
>>>
>>>
>>>
>>>
>>>
>>>> Hello:
>>>
>>>> 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
>>> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home
>>> "When all else fails, RTFM."- Hide quoted text -
>>>
>>> - Show quoted text -
>>
>> Perfect! Thanks!
>
> This is interesting, but what if there is no space separating the months and dates? How can you separate those into two columns?
>
> Thanks
>
0
Art
12/13/2013 1:02:32 PM
On 13/12/2013 8:02 AM, Art Kendall wrote:
> data list list / datestr(a25).
> begin data
> "January 12/1/2010"
> "March 4/3/1998"
> "February 8/17/1990"
> "January12/1/2010"
> "March4/3/1998"
> "February8/17/1990"
> end data.
> string workstring (a25).
> compute workstring ="".
> do repeat index= 1 to 25.
>     do if  not range(substr(datestr,index,1), "A","Z","a", "z").
>        compute workstring =
> concat(rtrim(workstring),substr(datestr,index,1)).
>     end if.
> end repeat.
> numeric mydate(adate10).
> compute mydate = number(workstring,adate10).
> list.
>
>
> Art Kendall
> Social Research Consultants

Here's a variation on Art's code without the workstring variable (which 
you would probably end up deleting afterwards).


NUMERIC MyDate(adate10).
COMPUTE #i = 0. /* #i = index variable for looping.
LOOP.
- COMPUTE #i = #i+1.
END LOOP if range(substr(datestr,#i,1), "0","9").
COMPUTE MyDate = NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
LIST.

Output:

datestr                       MyDate

January 12/1/2010         12/01/2010
March 4/3/1998            04/03/1998
February 8/17/1990        08/17/1990
January12/1/2010          12/01/2010
March4/3/1998             04/03/1998
February8/17/1990         08/17/1990

Number of cases read:  6    Number of cases listed:  6

HTH.

-- 
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0
Bruce
12/13/2013 2:18:18 PM
On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
> On 13/12/2013 8:02 AM, Art Kendall wrote:
> 
> > data list list / datestr(a25).
> 
> > begin data
> 
> > "January 12/1/2010"
> 
> > "March 4/3/1998"
> 
> > "February 8/17/1990"
> 
> > "January12/1/2010"
> 
> > "March4/3/1998"
> 
> > "February8/17/1990"
> 
> > end data.
> 
> > string workstring (a25).
> 
> > compute workstring ="".
> 
> > do repeat index= 1 to 25.
> 
> >     do if  not range(substr(datestr,index,1), "A","Z","a", "z").
> 
> >        compute workstring =
> 
> > concat(rtrim(workstring),substr(datestr,index,1)).
> 
> >     end if.
> 
> > end repeat.
> 
> > numeric mydate(adate10).
> 
> > compute mydate = number(workstring,adate10).
> 
> > list.
> 
> >
> 
> >
> 
> > Art Kendall
> 
> > Social Research Consultants
> 
> 
> 
> Here's a variation on Art's code without the workstring variable (which 
> 
> you would probably end up deleting afterwards).
> 
> 
> 
> 
> 
> NUMERIC MyDate(adate10).
> 
> COMPUTE #i = 0. /* #i = index variable for looping.
> 
> LOOP.
> 
> - COMPUTE #i = #i+1.
> 
> END LOOP if range(substr(datestr,#i,1), "0","9").
> 
> COMPUTE MyDate = NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
> 
> LIST.
> 
> 
> 
> Output:
> 
> 
> 
> datestr                       MyDate
> 
> 
> 
> January 12/1/2010         12/01/2010
> 
> March 4/3/1998            04/03/1998
> 
> February 8/17/1990        08/17/1990
> 
> January12/1/2010          12/01/2010
> 
> March4/3/1998             04/03/1998
> 
> February8/17/1990         08/17/1990
> 
> 
> 
> Number of cases read:  6    Number of cases listed:  6
> 
> 
> 
> HTH.
> 
> 
> 
> -- 
> 
> Bruce Weaver
> 
> bweaver@lakeheadu.ca
> 
> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
> 
> "When all else fails, RTFM."

REALLY GUYS? ;-)) Must be late on Friday?
--
COMPUTE mydate=NUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789",1)),ADATE10).
FORMATS mydate (ADATE10).
LIST.
0
David
12/13/2013 10:00:16 PM
People always seem to forget that magickal 3rd argument for INDEX!

On Friday, December 13, 2013 5:00:16 PM UTC-5, David Marso wrote:
> On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
> 
> > On 13/12/2013 8:02 AM, Art Kendall wrote:
> 
> > 
> 
> > > data list list / datestr(a25).
> 
> > 
> 
> > > begin data
> 
> > 
> 
> > > "January 12/1/2010"
> 
> > 
> 
> > > "March 4/3/1998"
> 
> > 
> 
> > > "February 8/17/1990"
> 
> > 
> 
> > > "January12/1/2010"
> 
> > 
> 
> > > "March4/3/1998"
> 
> > 
> 
> > > "February8/17/1990"
> 
> > 
> 
> > > end data.
> 
> > 
> 
> > > string workstring (a25).
> 
> > 
> 
> > > compute workstring ="".
> 
> > 
> 
> > > do repeat index= 1 to 25.
> 
> > 
> 
> > >     do if  not range(substr(datestr,index,1), "A","Z","a", "z").
> 
> > 
> 
> > >        compute workstring =
> 
> > 
> 
> > > concat(rtrim(workstring),substr(datestr,index,1)).
> 
> > 
> 
> > >     end if.
> 
> > 
> 
> > > end repeat.
> 
> > 
> 
> > > numeric mydate(adate10).
> 
> > 
> 
> > > compute mydate = number(workstring,adate10).
> 
> > 
> 
> > > list.
> 
> > 
> 
> > >
> 
> > 
> 
> > >
> 
> > 
> 
> > > Art Kendall
> 
> > 
> 
> > > Social Research Consultants
> 
> > 
> 
> > 
> 
> > 
> 
> > Here's a variation on Art's code without the workstring variable (which 
> 
> > 
> 
> > you would probably end up deleting afterwards).
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > NUMERIC MyDate(adate10).
> 
> > 
> 
> > COMPUTE #i = 0. /* #i = index variable for looping.
> 
> > 
> 
> > LOOP.
> 
> > 
> 
> > - COMPUTE #i = #i+1.
> 
> > 
> 
> > END LOOP if range(substr(datestr,#i,1), "0","9").
> 
> > 
> 
> > COMPUTE MyDate = NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
> 
> > 
> 
> > LIST.
> 
> > 
> 
> > 
> 
> > 
> 
> > Output:
> 
> > 
> 
> > 
> 
> > 
> 
> > datestr                       MyDate
> 
> > 
> 
> > 
> 
> > 
> 
> > January 12/1/2010         12/01/2010
> 
> > 
> 
> > March 4/3/1998            04/03/1998
> 
> > 
> 
> > February 8/17/1990        08/17/1990
> 
> > 
> 
> > January12/1/2010          12/01/2010
> 
> > 
> 
> > March4/3/1998             04/03/1998
> 
> > 
> 
> > February8/17/1990         08/17/1990
> 
> > 
> 
> > 
> 
> > 
> 
> > Number of cases read:  6    Number of cases listed:  6
> 
> > 
> 
> > 
> 
> > 
> 
> > HTH.
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > Bruce Weaver
> 
> > 
> 
> > bweaver@lakeheadu.ca
> 
> > 
> 
> > http://sites.google.com/a/lakeheadu.ca/bweaver/Home
> 
> > 
> 
> > "When all else fails, RTFM."
> 
> 
> 
> REALLY GUYS? ;-)) Must be late on Friday?
> 
> --
> 
> COMPUTE mydate=NUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789",1)),ADATE10).
> 
> FORMATS mydate (ADATE10).
> 
> LIST.

0
David
12/13/2013 10:02:09 PM
nice one!

Art Kendall
Social Research Consultants

On 12/13/2013 5:02 PM, David Marso wrote:
> People always seem to forget that magickal 3rd argument for INDEX!
>
> On Friday, December 13, 2013 5:00:16 PM UTC-5, David Marso wrote:
>> On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
>>
>>> On 13/12/2013 8:02 AM, Art Kendall wrote:
>>
>>>
>>
>>>> data list list / datestr(a25).
>>
>>>
>>
>>>> begin data
>>
>>>
>>
>>>> "January 12/1/2010"
>>
>>>
>>
>>>> "March 4/3/1998"
>>
>>>
>>
>>>> "February 8/17/1990"
>>
>>>
>>
>>>> "January12/1/2010"
>>
>>>
>>
>>>> "March4/3/1998"
>>
>>>
>>
>>>> "February8/17/1990"
>>
>>>
>>
>>>> end data.
>>
>>>
>>
>>>> string workstring (a25).
>>
>>>
>>
>>>> compute workstring ="".
>>
>>>
>>
>>>> do repeat index= 1 to 25.
>>
>>>
>>
>>>>      do if  not range(substr(datestr,index,1), "A","Z","a", "z").
>>
>>>
>>
>>>>         compute workstring =
>>
>>>
>>
>>>> concat(rtrim(workstring),substr(datestr,index,1)).
>>
>>>
>>
>>>>      end if.
>>
>>>
>>
>>>> end repeat.
>>
>>>
>>
>>>> numeric mydate(adate10).
>>
>>>
>>
>>>> compute mydate = number(workstring,adate10).
>>
>>>
>>
>>>> list.
>>
>>>
>>
>>>>
>>
>>>
>>
>>>>
>>
>>>
>>
>>>> Art Kendall
>>
>>>
>>
>>>> Social Research Consultants
>>
>>>
>>
>>>
>>
>>>
>>
>>> Here's a variation on Art's code without the workstring variable (which
>>
>>>
>>
>>> you would probably end up deleting afterwards).
>>
>>>
>>
>>>
>>
>>>
>>
>>>
>>
>>>
>>
>>> NUMERIC MyDate(adate10).
>>
>>>
>>
>>> COMPUTE #i = 0. /* #i = index variable for looping.
>>
>>>
>>
>>> LOOP.
>>
>>>
>>
>>> - COMPUTE #i = #i+1.
>>
>>>
>>
>>> END LOOP if range(substr(datestr,#i,1), "0","9").
>>
>>>
>>
>>> COMPUTE MyDate = NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
>>
>>>
>>
>>> LIST.
>>
>>>
>>
>>>
>>
>>>
>>
>>> Output:
>>
>>>
>>
>>>
>>
>>>
>>
>>> datestr                       MyDate
>>
>>>
>>
>>>
>>
>>>
>>
>>> January 12/1/2010         12/01/2010
>>
>>>
>>
>>> March 4/3/1998            04/03/1998
>>
>>>
>>
>>> February 8/17/1990        08/17/1990
>>
>>>
>>
>>> January12/1/2010          12/01/2010
>>
>>>
>>
>>> March4/3/1998             04/03/1998
>>
>>>
>>
>>> February8/17/1990         08/17/1990
>>
>>>
>>
>>>
>>
>>>
>>
>>> Number of cases read:  6    Number of cases listed:  6
>>
>>>
>>
>>>
>>
>>>
>>
>>> HTH.
>>
>>>
>>
>>>
>>
>>>
>>
>>> --
>>
>>>
>>
>>> Bruce Weaver
>>
>>>
>>
>>> bweaver@lakeheadu.ca
>>
>>>
>>
>>> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>>
>>>
>>
>>> "When all else fails, RTFM."
>>
>>
>>
>> REALLY GUYS? ;-)) Must be late on Friday?
>>
>> --
>>
>> COMPUTE mydate=NUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789",1)),ADATE10).
>>
>> FORMATS mydate (ADATE10).
>>
>> LIST.
>
0
Art
12/13/2013 11:49:00 PM
Yes, very nice.  From the FM:

CHAR.INDEX(haystack, needle[, divisor]). Numeric. Returns a number 
indicating the character position of the first occurrence of needle in 
haystack. The optional third argument, divisor, is a number of 
characters used to divide needle into separate strings. Each substring 
is used for searching and the function returns the first occurrence of 
any of the substrings. For example, CHAR.INDEX(var1, 'abcd') will return 
the value of the starting position of the complete string "abcd" in the 
string variable var1; CHAR.INDEX(var1, 'abcd', 1) will return the value 
of the position of the first occurrence of any of the values in the 
string; and CHAR.INDEX(var1,'abcd', 2) will return the value of the 
first occurrence of either "ab" or "cd". Divisor must be a positive 
integer and must divide evenly into the length of needle. Returns 0 if 
needle does not occur within haystack.

The key bit of that that David's solution takes advantage of is this:

CHAR.INDEX(var1, 'abcd', 1) will return the value of the position of the 
first occurrence of any of the values in the string; and 
CHAR.INDEX(var1,'abcd', 2) will return the value of the first occurrence 
of either "ab" or "cd".

Interesting that the last example returns the position of the first 
occurrence of "ab" or "cd", but not of "bc".


On 13/12/2013 6:49 PM, Art Kendall wrote:
> nice one!
>
> Art Kendall
> Social Research Consultants
>
> On 12/13/2013 5:02 PM, David Marso wrote:
>> People always seem to forget that magickal 3rd argument for INDEX!
>>
>> On Friday, December 13, 2013 5:00:16 PM UTC-5, David Marso wrote:
>>> On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
>>>
>>>> On 13/12/2013 8:02 AM, Art Kendall wrote:
>>>
>>>>
>>>
>>>>> data list list / datestr(a25).
>>>
>>>>
>>>
>>>>> begin data
>>>
>>>>
>>>
>>>>> "January 12/1/2010"
>>>
>>>>
>>>
>>>>> "March 4/3/1998"
>>>
>>>>
>>>
>>>>> "February 8/17/1990"
>>>
>>>>
>>>
>>>>> "January12/1/2010"
>>>
>>>>
>>>
>>>>> "March4/3/1998"
>>>
>>>>
>>>
>>>>> "February8/17/1990"
>>>
>>>>
>>>
>>>>> end data.
>>>
>>>>
>>>
>>>>> string workstring (a25).
>>>
>>>>
>>>
>>>>> compute workstring ="".
>>>
>>>>
>>>
>>>>> do repeat index= 1 to 25.
>>>
>>>>
>>>
>>>>>      do if  not range(substr(datestr,index,1), "A","Z","a", "z").
>>>
>>>>
>>>
>>>>>         compute workstring =
>>>
>>>>
>>>
>>>>> concat(rtrim(workstring),substr(datestr,index,1)).
>>>
>>>>
>>>
>>>>>      end if.
>>>
>>>>
>>>
>>>>> end repeat.
>>>
>>>>
>>>
>>>>> numeric mydate(adate10).
>>>
>>>>
>>>
>>>>> compute mydate = number(workstring,adate10).
>>>
>>>>
>>>
>>>>> list.
>>>
>>>>
>>>
>>>>>
>>>
>>>>
>>>
>>>>>
>>>
>>>>
>>>
>>>>> Art Kendall
>>>
>>>>
>>>
>>>>> Social Research Consultants
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> Here's a variation on Art's code without the workstring variable (which
>>>
>>>>
>>>
>>>> you would probably end up deleting afterwards).
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> NUMERIC MyDate(adate10).
>>>
>>>>
>>>
>>>> COMPUTE #i = 0. /* #i = index variable for looping.
>>>
>>>>
>>>
>>>> LOOP.
>>>
>>>>
>>>
>>>> - COMPUTE #i = #i+1.
>>>
>>>>
>>>
>>>> END LOOP if range(substr(datestr,#i,1), "0","9").
>>>
>>>>
>>>
>>>> COMPUTE MyDate = NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
>>>
>>>>
>>>
>>>> LIST.
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> Output:
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> datestr                       MyDate
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> January 12/1/2010         12/01/2010
>>>
>>>>
>>>
>>>> March 4/3/1998            04/03/1998
>>>
>>>>
>>>
>>>> February 8/17/1990        08/17/1990
>>>
>>>>
>>>
>>>> January12/1/2010          12/01/2010
>>>
>>>>
>>>
>>>> March4/3/1998             04/03/1998
>>>
>>>>
>>>
>>>> February8/17/1990         08/17/1990
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> Number of cases read:  6    Number of cases listed:  6
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> HTH.
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> --
>>>
>>>>
>>>
>>>> Bruce Weaver
>>>
>>>>
>>>
>>>> bweaver@lakeheadu.ca
>>>
>>>>
>>>
>>>> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>>>
>>>>
>>>
>>>> "When all else fails, RTFM."
>>>
>>>
>>>
>>> REALLY GUYS? ;-)) Must be late on Friday?
>>>
>>> --
>>>
>>> COMPUTE
>>> mydate=NUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789",1)),ADATE10).
>>>
>>>
>>> FORMATS mydate (ADATE10).
>>>
>>> LIST.
>>


-- 
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0
Bruce
12/14/2013 2:35:41 AM
"Interesting that the last example returns the position of the first=20
occurrence of "ab" or "cd", but not of "bc". "
It chops the needle into substrings the size of divisor then scans the hays=
tack for each parsed element.  If one wanted to do what you propose you cou=
ld build an array of moving chunks and then INDEX each of those.  Not going=
 to write it today. Would be easy to do.

On Friday, December 13, 2013 9:35:41 PM UTC-5, Bruce Weaver wrote:
> Yes, very nice.  From the FM:
>=20
>=20
>=20
> CHAR.INDEX(haystack, needle[, divisor]). Numeric. Returns a number=20
>=20
> indicating the character position of the first occurrence of needle in=20
>=20
> haystack. The optional third argument, divisor, is a number of=20
>=20
> characters used to divide needle into separate strings. Each substring=20
>=20
> is used for searching and the function returns the first occurrence of=20
>=20
> any of the substrings. For example, CHAR.INDEX(var1, 'abcd') will return=
=20
>=20
> the value of the starting position of the complete string "abcd" in the=
=20
>=20
> string variable var1; CHAR.INDEX(var1, 'abcd', 1) will return the value=
=20
>=20
> of the position of the first occurrence of any of the values in the=20
>=20
> string; and CHAR.INDEX(var1,'abcd', 2) will return the value of the=20
>=20
> first occurrence of either "ab" or "cd". Divisor must be a positive=20
>=20
> integer and must divide evenly into the length of needle. Returns 0 if=20
>=20
> needle does not occur within haystack.
>=20
>=20
>=20
> The key bit of that that David's solution takes advantage of is this:
>=20
>=20
>=20
> CHAR.INDEX(var1, 'abcd', 1) will return the value of the position of the=
=20
>=20
> first occurrence of any of the values in the string; and=20
>=20
> CHAR.INDEX(var1,'abcd', 2) will return the value of the first occurrence=
=20
>=20
> of either "ab" or "cd".
>=20
>=20
>=20
> Interesting that the last example returns the position of the first=20
>=20
> occurrence of "ab" or "cd", but not of "bc".
>=20
>=20
>=20
>=20
>=20
> On 13/12/2013 6:49 PM, Art Kendall wrote:
>=20
> > nice one!
>=20
> >
>=20
> > Art Kendall
>=20
> > Social Research Consultants
>=20
> >
>=20
> > On 12/13/2013 5:02 PM, David Marso wrote:
>=20
> >> People always seem to forget that magickal 3rd argument for INDEX!
>=20
> >>
>=20
> >> On Friday, December 13, 2013 5:00:16 PM UTC-5, David Marso wrote:
>=20
> >>> On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
>=20
> >>>
>=20
> >>>> On 13/12/2013 8:02 AM, Art Kendall wrote:
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> data list list / datestr(a25).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> begin data
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> "January 12/1/2010"
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> "March 4/3/1998"
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> "February 8/17/1990"
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> "January12/1/2010"
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> "March4/3/1998"
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> "February8/17/1990"
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> end data.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> string workstring (a25).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> compute workstring =3D"".
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> do repeat index=3D 1 to 25.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>>      do if  not range(substr(datestr,index,1), "A","Z","a", "z").
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>>         compute workstring =3D
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> concat(rtrim(workstring),substr(datestr,index,1)).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>>      end if.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> end repeat.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> numeric mydate(adate10).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> compute mydate =3D number(workstring,adate10).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> list.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> Art Kendall
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>> Social Research Consultants
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> Here's a variation on Art's code without the workstring variable (wh=
ich
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> you would probably end up deleting afterwards).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> NUMERIC MyDate(adate10).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> COMPUTE #i =3D 0. /* #i =3D index variable for looping.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> LOOP.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> - COMPUTE #i =3D #i+1.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> END LOOP if range(substr(datestr,#i,1), "0","9").
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> COMPUTE MyDate =3D NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> LIST.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> Output:
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> datestr                       MyDate
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> January 12/1/2010         12/01/2010
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> March 4/3/1998            04/03/1998
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> February 8/17/1990        08/17/1990
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> January12/1/2010          12/01/2010
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> March4/3/1998             04/03/1998
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> February8/17/1990         08/17/1990
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> Number of cases read:  6    Number of cases listed:  6
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> HTH.
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> --
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> Bruce Weaver
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> bweaver@lakeheadu.ca
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>=20
> >>>
>=20
> >>>>
>=20
> >>>
>=20
> >>>> "When all else fails, RTFM."
>=20
> >>>
>=20
> >>>
>=20
> >>>
>=20
> >>> REALLY GUYS? ;-)) Must be late on Friday?
>=20
> >>>
>=20
> >>> --
>=20
> >>>
>=20
> >>> COMPUTE
>=20
> >>> mydate=3DNUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789",1=
)),ADATE10).
>=20
> >>>
>=20
> >>>
>=20
> >>> FORMATS mydate (ADATE10).
>=20
> >>>
>=20
> >>> LIST.
>=20
> >>
>=20
>=20
>=20
>=20
>=20
> --=20
>=20
> Bruce Weaver
>=20
> bweaver@lakeheadu.ca
>=20
> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>=20
> "When all else fails, RTFM."

0
David
12/14/2013 5:10:30 PM
So CHAR.INDEX(var1,'abbccd',2) would find the position of the first 
occurrence of 'ab', 'bc' or 'cd' in var1.


On 14/12/2013 12:10 PM, David Marso wrote:
> "Interesting that the last example returns the position of the first
> occurrence of "ab" or "cd", but not of "bc". "
> It chops the needle into substrings the size of divisor then scans the haystack for each parsed element.  If one wanted to do what you propose you could build an array of moving chunks and then INDEX each of those.  Not going to write it today. Would be easy to do.
>
> On Friday, December 13, 2013 9:35:41 PM UTC-5, Bruce Weaver wrote:
>> Yes, very nice.  From the FM:
>>
>>
>>
>> CHAR.INDEX(haystack, needle[, divisor]). Numeric. Returns a number
>>
>> indicating the character position of the first occurrence of needle in
>>
>> haystack. The optional third argument, divisor, is a number of
>>
>> characters used to divide needle into separate strings. Each substring
>>
>> is used for searching and the function returns the first occurrence of
>>
>> any of the substrings. For example, CHAR.INDEX(var1, 'abcd') will return
>>
>> the value of the starting position of the complete string "abcd" in the
>>
>> string variable var1; CHAR.INDEX(var1, 'abcd', 1) will return the value
>>
>> of the position of the first occurrence of any of the values in the
>>
>> string; and CHAR.INDEX(var1,'abcd', 2) will return the value of the
>>
>> first occurrence of either "ab" or "cd". Divisor must be a positive
>>
>> integer and must divide evenly into the length of needle. Returns 0 if
>>
>> needle does not occur within haystack.
>>
>>
>>
>> The key bit of that that David's solution takes advantage of is this:
>>
>>
>>
>> CHAR.INDEX(var1, 'abcd', 1) will return the value of the position of the
>>
>> first occurrence of any of the values in the string; and
>>
>> CHAR.INDEX(var1,'abcd', 2) will return the value of the first occurrence
>>
>> of either "ab" or "cd".
>>
>>
>>
>> Interesting that the last example returns the position of the first
>>
>> occurrence of "ab" or "cd", but not of "bc".
>>
>>
>>
>>
>>
>> On 13/12/2013 6:49 PM, Art Kendall wrote:
>>
>>> nice one!
>>
>>>
>>
>>> Art Kendall
>>
>>> Social Research Consultants
>>
>>>
>>
>>> On 12/13/2013 5:02 PM, David Marso wrote:
>>
>>>> People always seem to forget that magickal 3rd argument for INDEX!
>>
>>>>
>>
>>>> On Friday, December 13, 2013 5:00:16 PM UTC-5, David Marso wrote:
>>
>>>>> On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
>>
>>>>>
>>
>>>>>> On 13/12/2013 8:02 AM, Art Kendall wrote:
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> data list list / datestr(a25).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> begin data
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> "January 12/1/2010"
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> "March 4/3/1998"
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> "February 8/17/1990"
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> "January12/1/2010"
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> "March4/3/1998"
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> "February8/17/1990"
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> end data.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> string workstring (a25).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> compute workstring ="".
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> do repeat index= 1 to 25.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>>       do if  not range(substr(datestr,index,1), "A","Z","a", "z").
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>>          compute workstring =
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> concat(rtrim(workstring),substr(datestr,index,1)).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>>       end if.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> end repeat.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> numeric mydate(adate10).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> compute mydate = number(workstring,adate10).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> list.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> Art Kendall
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>> Social Research Consultants
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> Here's a variation on Art's code without the workstring variable (which
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> you would probably end up deleting afterwards).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> NUMERIC MyDate(adate10).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> COMPUTE #i = 0. /* #i = index variable for looping.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> LOOP.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> - COMPUTE #i = #i+1.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> END LOOP if range(substr(datestr,#i,1), "0","9").
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> COMPUTE MyDate = NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> LIST.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> Output:
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> datestr                       MyDate
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> January 12/1/2010         12/01/2010
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> March 4/3/1998            04/03/1998
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> February 8/17/1990        08/17/1990
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> January12/1/2010          12/01/2010
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> March4/3/1998             04/03/1998
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> February8/17/1990         08/17/1990
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> Number of cases read:  6    Number of cases listed:  6
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> HTH.
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> --
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> Bruce Weaver
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> bweaver@lakeheadu.ca
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>>
>>>>>
>>
>>>>>>
>>
>>>>>
>>
>>>>>> "When all else fails, RTFM."
>>
>>>>>
>>
>>>>>
>>
>>>>>
>>
>>>>> REALLY GUYS? ;-)) Must be late on Friday?
>>
>>>>>
>>
>>>>> --
>>
>>>>>
>>
>>>>> COMPUTE
>>
>>>>> mydate=NUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789",1)),ADATE10).
>>
>>>>>
>>
>>>>>
>>
>>>>> FORMATS mydate (ADATE10).
>>
>>>>>
>>
>>>>> LIST.
>>
>>>>
>>
>>
>>
>>
>>
>> --
>>
>> Bruce Weaver
>>
>> bweaver@lakeheadu.ca
>>
>> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>>
>> "When all else fails, RTFM."
>


-- 
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0
Bruce
12/14/2013 8:28:51 PM
Inded!
DATA LIST FREE /teststring (A10).
BEGIN DATA
abdghfhjkj
dfggsbcwer
ghfhhdjjjs
END DATA.
COMPUTE abbccd=3DCHAR.INDEX(teststring,"abbccd",2).
LIST.

teststring   abbccd=20
=20
abdghfhjkj     1.00=20
dfggsbcwer     6.00=20
ghfhhdjjjs      .00=20
=20
=20
Number of cases read:  3    Number of cases listed:  3
On Saturday, December 14, 2013 3:28:51 PM UTC-5, Bruce Weaver wrote:
> So CHAR.INDEX(var1,'abbccd',2) would find the position of the first=20
>=20
> occurrence of 'ab', 'bc' or 'cd' in var1.
>=20
>=20
>=20
>=20
>=20
> On 14/12/2013 12:10 PM, David Marso wrote:
>=20
> > "Interesting that the last example returns the position of the first
>=20
> > occurrence of "ab" or "cd", but not of "bc". "
>=20
> > It chops the needle into substrings the size of divisor then scans the =
haystack for each parsed element.  If one wanted to do what you propose you=
 could build an array of moving chunks and then INDEX each of those.  Not g=
oing to write it today. Would be easy to do.
>=20
> >
>=20
> > On Friday, December 13, 2013 9:35:41 PM UTC-5, Bruce Weaver wrote:
>=20
> >> Yes, very nice.  From the FM:
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >> CHAR.INDEX(haystack, needle[, divisor]). Numeric. Returns a number
>=20
> >>
>=20
> >> indicating the character position of the first occurrence of needle in
>=20
> >>
>=20
> >> haystack. The optional third argument, divisor, is a number of
>=20
> >>
>=20
> >> characters used to divide needle into separate strings. Each substring
>=20
> >>
>=20
> >> is used for searching and the function returns the first occurrence of
>=20
> >>
>=20
> >> any of the substrings. For example, CHAR.INDEX(var1, 'abcd') will retu=
rn
>=20
> >>
>=20
> >> the value of the starting position of the complete string "abcd" in th=
e
>=20
> >>
>=20
> >> string variable var1; CHAR.INDEX(var1, 'abcd', 1) will return the valu=
e
>=20
> >>
>=20
> >> of the position of the first occurrence of any of the values in the
>=20
> >>
>=20
> >> string; and CHAR.INDEX(var1,'abcd', 2) will return the value of the
>=20
> >>
>=20
> >> first occurrence of either "ab" or "cd". Divisor must be a positive
>=20
> >>
>=20
> >> integer and must divide evenly into the length of needle. Returns 0 if
>=20
> >>
>=20
> >> needle does not occur within haystack.
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >> The key bit of that that David's solution takes advantage of is this:
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >> CHAR.INDEX(var1, 'abcd', 1) will return the value of the position of t=
he
>=20
> >>
>=20
> >> first occurrence of any of the values in the string; and
>=20
> >>
>=20
> >> CHAR.INDEX(var1,'abcd', 2) will return the value of the first occurren=
ce
>=20
> >>
>=20
> >> of either "ab" or "cd".
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >> Interesting that the last example returns the position of the first
>=20
> >>
>=20
> >> occurrence of "ab" or "cd", but not of "bc".
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >> On 13/12/2013 6:49 PM, Art Kendall wrote:
>=20
> >>
>=20
> >>> nice one!
>=20
> >>
>=20
> >>>
>=20
> >>
>=20
> >>> Art Kendall
>=20
> >>
>=20
> >>> Social Research Consultants
>=20
> >>
>=20
> >>>
>=20
> >>
>=20
> >>> On 12/13/2013 5:02 PM, David Marso wrote:
>=20
> >>
>=20
> >>>> People always seem to forget that magickal 3rd argument for INDEX!
>=20
> >>
>=20
> >>>>
>=20
> >>
>=20
> >>>> On Friday, December 13, 2013 5:00:16 PM UTC-5, David Marso wrote:
>=20
> >>
>=20
> >>>>> On Friday, December 13, 2013 9:18:18 AM UTC-5, Bruce Weaver wrote:
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> On 13/12/2013 8:02 AM, Art Kendall wrote:
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> data list list / datestr(a25).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> begin data
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> "January 12/1/2010"
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> "March 4/3/1998"
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> "February 8/17/1990"
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> "January12/1/2010"
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> "March4/3/1998"
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> "February8/17/1990"
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> end data.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> string workstring (a25).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> compute workstring =3D"".
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> do repeat index=3D 1 to 25.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>>       do if  not range(substr(datestr,index,1), "A","Z","a", "z")=
..
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>>          compute workstring =3D
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> concat(rtrim(workstring),substr(datestr,index,1)).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>>       end if.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> end repeat.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> numeric mydate(adate10).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> compute mydate =3D number(workstring,adate10).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> list.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> Art Kendall
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>> Social Research Consultants
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> Here's a variation on Art's code without the workstring variable (=
which
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> you would probably end up deleting afterwards).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> NUMERIC MyDate(adate10).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> COMPUTE #i =3D 0. /* #i =3D index variable for looping.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> LOOP.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> - COMPUTE #i =3D #i+1.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> END LOOP if range(substr(datestr,#i,1), "0","9").
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> COMPUTE MyDate =3D NUMBER(CHAR.SUBSTR(datestr,#i),adate10).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> LIST.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> Output:
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> datestr                       MyDate
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> January 12/1/2010         12/01/2010
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> March 4/3/1998            04/03/1998
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> February 8/17/1990        08/17/1990
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> January12/1/2010          12/01/2010
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> March4/3/1998             04/03/1998
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> February8/17/1990         08/17/1990
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> Number of cases read:  6    Number of cases listed:  6
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> HTH.
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> --
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> Bruce Weaver
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> bweaver@lakeheadu.ca
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>> "When all else fails, RTFM."
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>> REALLY GUYS? ;-)) Must be late on Friday?
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>> --
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>> COMPUTE
>=20
> >>
>=20
> >>>>> mydate=3DNUMBER(CHAR.SUBSTR(datestr,CHAR.INDEX(datestr,"0123456789"=
,1)),ADATE10).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>> FORMATS mydate (ADATE10).
>=20
> >>
>=20
> >>>>>
>=20
> >>
>=20
> >>>>> LIST.
>=20
> >>
>=20
> >>>>
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >>
>=20
> >> --
>=20
> >>
>=20
> >> Bruce Weaver
>=20
> >>
>=20
> >> bweaver@lakeheadu.ca
>=20
> >>
>=20
> >> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>=20
> >>
>=20
> >> "When all else fails, RTFM."
>=20
> >
>=20
>=20
>=20
>=20
>=20
> --=20
>=20
> Bruce Weaver
>=20
> bweaver@lakeheadu.ca
>=20
> http://sites.google.com/a/lakeheadu.ca/bweaver/Home
>=20
> "When all else fails, RTFM."

0
David
12/15/2013 12:15:42 AM
On Thursday, 25 March 2010 07:34:18 UTC+11, Ryan  wrote:
> Hello:
> 
> 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 guys,
I have a similar situation.
two string variables have same or different information in same or reverse order separated by "," e.g:
ab12,cd56     cd56,ab12
ab12,cd56     ab12,cd56
ab12          fx54
ab12,ac34,k4  lx1,km55

I want to create one variable with only unique entries from the two variables.
any suggestions?
Regards,
e.g
0
SS
5/16/2014 7:55:42 AM
Please start a NEW thread rather than jumping an old one from 4 years ago.
Next time also include what you would want as the result!
What do you expect from the 3rd and 4th example?
For case 1 and 2 look at CHAR.INDEX, CHAR.SUBSTR, CONCAT and MIN and MAX functions

On Friday, May 16, 2014 3:55:42 AM UTC-4, SS wrote:
> On Thursday, 25 March 2010 07:34:18 UTC+11, Ryan  wrote:
> 
> > Hello:
> 
> > 
> 
> > 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 guys,
> 
> I have a similar situation.
> 
> two string variables have same or different information in same or reverse order separated by "," e.g:
> 
> ab12,cd56     cd56,ab12
> 
> ab12,cd56     ab12,cd56
> 
> ab12          fx54
> 
> ab12,ac34,k4  lx1,km55
> 
> 
> 
> I want to create one variable with only unique entries from the two variables.
> 
> any suggestions?
> 
> Regards,
> 
> e.g

0
David
5/16/2014 8:21:13 AM
I have started new post. 
My problem is very clearly stated. Can you help?
0
SS
5/16/2014 10:49:04 AM
Reply:

Similar Artilces:

comparing character strings or character strings as variables
I want to write a MATLAB function that will allow me to compare an array of characters to see if there are any repeats of character strings in the array, and I am not able to find any information in any documentation/books that says anything about storing a string of characters as a variable. Does anyone have any idea how this could be done in MATLAB? Thanks, Stephen Stephen wrote: > > > I want to write a MATLAB function that will allow me to compare an > array of characters to see if there are any repeats of character > strings in the array, and I am not able to find any inf...

Deleting a character in string variable
Hello all, I am trying to delete a character "-" in study_id variable and to convert it from string to numeric. (1-2345 to 12345). I checked the group archives and found this code: comp studyid=3Dnumber(concat(substr(string(study_id,f6), 1,1),substr(string(study_id,f6),3,4))=AD,f5). Tried it but gave me this error: >Error # 4310 in column 48. Text: ) >The numeric argument required for the function specified was not supplied. >This command not executed. I am using v.13. Is that a problem? How can I make it work? Thanks, Asil On Sep 25, 3:59=A0...

Automatic Character deletion within string after detecting a special character
Suppose I have a string "Take me home, cas<<ountry rosd<<ad." I want to write a script to detect each < as a cue for backspace, making the string read as follows: "Take me home, country road." deleting the < as well as the preceding character. How can this be done? "Adrian " <bechaotik@gmail.com> wrote in message <i18l3c$k9o$1@fred.mathworks.com>... > Suppose I have a string "Take me home, cas<<ountry rosd<<ad." > I want to write a script to detect each < as a cue for backspace, making the s...

How to replace a variable string within /* variable_string */ with x for each character in string?
How to replace a variable string within /* variable_string */ with x for each character in string? The string may span on multiple lines. for eaxmple: /* string */ -> /* xxxxxx */ /* stringstring */ -> /* xxxxxxxxxxxx */ /* string1 string2 */ -> /* xxxxxxx xxxxxxx */ Thanks, Victor X-Ftn-To: Victor gvictor97@yahoo.com (Victor) wrote: >How to replace a variable string within /* variable_string */ with x >for each character in string? > >The string may span on multiple lines. > >for eaxmple: > >/* string */ -> >/* xxxxxx */ > ...

Replacing a Character variable with part of another Character variable
Good evening all, I have a small problem that I need to solve and would appreciate any help you offer. I created the below table using some raw data. I created the Location variable using the ZIPCITY function. As you can see, in the last observation the City "Harrisbu" does not match the city under Location "Levittown" while for the first observation the Location is left blank because the zipcode is invalid. I need a simple code that does the following: 1.If they zipcode does not match the city/state (6th observation), create a code that suggests either edits to the zi...

Re: How to convert a string of character 40 to a string of characters
"kundu" <subhadarsan_kundu@yahoo.com> writes: > Sorry, > The target string will contain 20 characters. I tried with solution > given by Robin. Union used in the user defined function UNHEX is not > working in our version of PL1 in Mainframe. Could you pls let me know any > alternate approach ? > > Any way, thanks Robin for your support. Try this (with straight overlay defining): unhex: proc (h) returns (char(16383) varying) options (reorder); dcl h char(*), s char(length(h)), u(length(h)/2,4) bit(4) defined s; dcl t char(length(h)/...

reflection: variable -> string (not string -> variable)
is it possible to do something like the following? {{{ var example = {}; for(var i = 0; i < 10; i++) eval( nameof(example) + '_' + i + '= new Otherthing();'); }}} if so, how to do it? Yes in this example you just could write eval("example_" + i + "new Otherthing"); But if this for-loop is written in a context where the variable "example" can change to any other variable, you would have to write infinite lines of code. I would like to find another solution. ;-) and just not to be seen in the wrong light: 1. yes I used a lot of googling befor...

Deleting specific characters from a string
Hi all, I would like deleting specific characters from a string. As an example, I would like to delete all of the '@' '&' in the string 'You are ben@orange?enter&your&code' so that it becomes 'benorange?enteryourcode'. So far I have been doing it like: str = 'You are ben@orange?enter&your&code' str = ''.join([ c for c in str if c not in ('@', '&')]) but that looks so ugly.. I am hoping to see nicer examples to acheive the above.. Thanks. Ben. >>> import string >>> str = 'You a...

Replacing a Character variable with part of another Character variable #3
Good evening all, I have a small problem that I need to solve and would appreciate any help you offer. I created the below table using some raw data. I created the Location variable using the ZIPCITY function. As you can see, in the last observation the City "Harrisbu" does not match the city under Location "Levittown" while for the first observation the Location is left blank because the zipcode is invalid. I need a simple code that does the following: 1.If they zipcode does not match the city/state (6th observation), create a code that suggests either edits to the z...

Replacing a Character variable with part of another Character variable #2
Good evening all, I have a small problem that I need to solve and would appreciate any help you offer. I created the below table using some raw data. I created the Location variable using the ZIPCITY function. As you can see, in the last observation the City "Harrisbu" does not match the city under Location "Levittown" while for the first observation the Location is left blank because the zipcode is invalid. I need a simple code that does the following: 1.If they zipcode does not match the city/state (6th observation), create a code that suggests either edits to the z...

Adding a character to a string variable
Adding a letter to a string variable I get data from a national database. Unfortunately it is written to excel spreadsheet. The patients ID represented by their birthdays + 4 arbitrary numbers that make the ID unique (like 311295#### which is last day in the year 1995). The first day in 1996 is written 010196#### . But in the spreadsheet I receive the zero in front is omitted 10196####. Can anybody give me a clue: After changing the ID numbers to String variables, by which syntax I may add zero in front of all the cases that contain only nine (9) characters, w...

[AS] delete first character of string
See above the Entourage line a line that always bails with an error "Connection not allowed" tell application "iCal" set cs to calendars set calend to (get first calendar where title is "WM") -- unbelievable steve seems to disklike selection, which iCal does not know... -- so select a calendar by name -- set willi to position of (calend) in application calendars does not work in any way -- would use this for category in entourage (see bleow) set recte to "" repeat with calend in cs -- perhaps loop if calend is not writable set ind to title of calend set ev to events of calend tell application "Microsoft Entourage" set cate to (get categories where name is ind) if cate is {} then set cate to make new category with properties {name:ind} end tell repeat with j in ev if (date "Samstag, 1. Januar 2005 0:00:00 Uhr") < (start date of j) or (date "Dienstag, 1. Januar 2008 0:00:00 Uhr") < (start date of j) then set stdate to start date of j set endate to end date of j set da to allday event of j set te to "" & d...

Deleted unwanted characters from a string
Hi :) Im trying to write a script that can check if Rapidshare links are online, ive managed to get the content of [code] tags from my website using scrubyt [code]<root> <link>http://rapidshare.com/files/example/example.rar</link> [/code] Im trying to strip the string of anything but the "http://rapidshare.com/files/example/example.rar" part, so I can work with it. I tried to use the .delete function however it doesn’t work. [code]require 'rubygems' require 'scrubyt' data = Scrubyt::Extractor.define do fetch 'http://www.mywebsite.com...

How to delete specific characters from a string?
Is there really no method that allows me to delete N characters starting at position P from a string? I have looked (carefully I hope) through the String methods and did not see a way to do this. Thanks. Bazsl wrote: > Is there really no method that allows me to delete N characters starting > at position P from a string? I have looked (carefully I hope) through > the String methods and did not see a way to do this. Thanks. Try this: str = "hello world" str[0, 6] = '' puts str -- Posted via http://www.ruby-forum.com/. On 11-Oct-07, at 7:15 PM, Bazsl wrot...

How to delete a ast character from a string?
Hi, I've a list some of whose elements with character \. I want to delete this last character from the elements that have this character set at their end, I have written a small program, unfortunately this does not work: dirListFinal = [] for item in dirList: print item if item.endswith('\\') == True: item = item[0:-1] # This one I googled and found to remove the last character / dirListFinal.append(item) else: dirListFinal.append(item) item.endswith() does not seem to be working. Plea...

Re: How to convert a string of character 40 to a string of characters #8
Subject: Re: How to convert a string of character 40 to a string of characters From: "David Frank" <dave_frank@hotmail.com>, Road Runner High Speed Online http://www.rr.com Date: Sun, 05 Dec 2004 10:38:03 GMT .. | "robin" <robin_v@bigpond.mapson.com> wrote in message news:a3isd.58652$K7.33510@news-server.bigpond.net.au... | > Subject: Re: How to convert a string of character 40 to a string of | > characters | > From: "David Frank" <dave_frank@hotmail.com>, Road Runner High Speed online http://www.rr.com | > Date: Mon, 22 Nov 2004 18:...

Re: How to convert a string of character 40 to a string of characters #9
"David Frank" <dave_frank@hotmail.com> writes: > > "Mark Yudkin" <myudkinATcompuserveDOTcom@boing.org> wrote in message > news:cp69a4$5p8$1@ngspool-d02.news.aol.com... > > Tim, the specific compiler is irrelevant here. Fuckwit Frank has a > > fundamental logic flaw. He has totally ignored section 3.1 of the Fortran > > Reference, which clearly explains WHY his code will fail. > All this screaming and shouting ignores that my 3 -1 line statements WORK > and OUTPUT: Your code fails. RTM. ...

8 bit character string to 16 bit character string
Does the C standard include a library function to convert an 8 bit character string to a 16 bit character string? In article <e54og7$t0c$1@newshost.mot.com>, Brand Bogard <brand.bogard@motorola.com> wrote: >Does the C standard include a library function to convert an 8 bit character >string to a 16 bit character string? No. All that the C standard knows about char is that it is a -minimum- of 8 bits long. What might interest you, however is: wchar_t is value superset of char_t, so if you have an array of wchar_t and copy each member of a char array in the corresponding...

String function to delete characters
Hi all, Do we have a string function in RUBY to delete 1st 3 characters or last 3 character or 3 characters in middle from the string. Ex: user = aaaPrasadxxxPrasadxxx from above string "user" I want to delete 1st characters "aaa" In the same way I want to delete last 3 characters "xxx" and , need to delete middle 3 characters "xxx" to delete last 3 character & 1st 3 characters, i have used code as below; user = user.chop.chop.chop user = user.reverse.chop.chop.chop.reverse Other than this do we have any other...

How to delete a last character from a string
Sorry : Earlier mail had a typo in Subject line which might look in-appropriate to my friends Hi, I've a list some of whose elements with character \. I want to delete this last character from the elements that have this character set at their end, I have written a small program, unfortunately this does not work: dirListFinal = [] for item in dirList: print item if item.endswith('\\') == True: item = item[0:-1] # This one I googled and found to remove the last character / dirListFinal.append(item) else: ...

Re: How to convert a string of character 40 to a string of characters #6
"David Frank" <dave_frank@hotmail.com> writes: > > "robin" <robin_v@bigpond.mapson.com> wrote in message > news:gylod.44973$K7.32292@news-server.bigpond.net.au... > > > >> If it works, then post the program that you used to determine that it > >> works. > > > > The program that works has alrready been posted by Mark Yudkin. > > The only altered statement is the one above, and that works > > too. > > Yudkin and Robin (the dynamic duo) has never shown a single Windows PL/I > statement > to c...

Re: How to convert a string of character 40 to a string of characters #7
Subject: Re: How to convert a string of character 40 to a string of characters From: "David Frank" <dave_frank@hotmail.com>, Road Runner High Speed Online http://www.rr.com Date: Mon, 22 Nov 2004 18:12:21 GMT .. | whereas I have shown not one but 3 single statements to do this | directly in a Fortran exec WITHOUT using a user function. .. You haven't shown anything of the sort. ALL 3 of your single statements are full of bugs, and cause the the program to crash. They won't work at all on some systems. I told you this before. =================quote============== From: ...

adding character to string variable
There is so much out there on deleting characters from a string variable, but how would I go about adding one? I need to add a "#" to the end of a variable. Thanks! open a new instance of SPSS. paste the syntax below in t the syntax window. Run it. are one of these what you want? data list list /oldstring (a12). begin data 'abc def ghi' 'abc def ghi ' abcdef 1234567 +++++ ===== 'aaa bbb' ' aa' end data. string newstring1 newstring2 (a13). compute newstring1 = concat(oldstring, '#'). compute newstring2 = concat(rtrim(oldstri...

How to delete the space characters from the string
Hi all, Is there any library function in order to delete the space characters from the given stirng. Thanks, Jay jayapal said: > Hi all, > > Is there any library function in order to delete the space characters > from the given stirng. No, but see K&R2, page 47. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "Usenet is a strange place" - dmr 29 July 1999 In article <59ef9782-056d-4f82-9697-24d58d490d9c@d27g2000prf.googlegroups.com>, jayapal <jayapal40...

Web resources about - Deleting Characters from a String Variable - comp.soft-sys.stat.spss

Dilbert (character) - Wikipedia, the free encyclopedia
Dilbert is a fictional character and the main character and protagonist of the Dilbert comic strip . He is a white collar office worker who has ...

Just-released Daredevil season 2 trailer puts new characters in the spotlight
A week and a half ago, Netflix released the first full-length trailer for the second season of Daredevil . The trailer focused on the inevitable ...

How 'Disney Infinity' characters gets made - Business Insider
Nick Wilde and Judy Hopps will be two of the latest characters to join the growing franchise.

Andrew Lincoln on Walking Dead character’s relationship: ‘it feels right’
... third season. Showrunner Scott Gimple told EW that “ The Andrea story from the comics has been broken up and given to several different characters ...

11 Big Walking Dead Characters Who Died In Different Ways In The Comics
Here are 11 characters from AMC’s The Walking Dead that were killed off in significantly different ways from how they met their maker in the ...

‘The 100′: Is Pike the Most Hated Character on Television?
Carla Day breaks down why Charles Pike, played by Michael Beach, may be the most hated character on television; The 100 airs Thursday nights ...

Deadpool Movie Deleted Scenes And Rejected Characters
While no one is really complaining about something missing from Deadpool, there were numerous [...]

Dragon Quest Heroes II will have free character DLC
... Omega Force-developed hack-and-slash title and also confirmed a few good things. As picked up by Gematsu , there will be more returning characters ...

Christian Slater Sued by His Father for Defamation of Character and Slander
The 'Mr. Robot' star is facing a $20 million lawsuit after claiming his father had 'manic-depressive schizophrenia' in a 2015 interview.

Can You Guess the Dead Game of Thrones Character Who's Turning Winds of Winter Upside Down?
With its sixth season nearly here, Game of Thrones is ready to leapfrog where George R.R. Martin’s books left off, since Martin’s The Winds of ...

Resources last updated: 2/27/2016 10:45:30 AM