LTRIM

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

LTRIM

subscribe SPSSX-l Anonymous-2
Hi,

I have a Student ID field which has been combined with a Program ID field.
I need to remove the first 8 characters which is the Student's ID.  For some
reason it's removing the last 8 characters instead as if I was using RTRIM.
 Any help would be appreciated.

example of field:

0516895*ACC.ENTR.BAC


This is what I'm using:

DATASET ACTIVATE DataSet1.
COMPUTE newPID=LTRIM(newPROGID,"8").
EXECUTE.


Thanks,

Michelle

=====================
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: LTRIM

Marks, Jim
Michelle:

LTRIM removes leading blanks.

Try (not tested):

DATASET ACTIVATE DataSet1.
STRING newPID (a20).
COMPUTE newPID=SUBSTR(newPROGID,9,29).
EXECUTE.

--jim


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Michelle
Sent: Thursday, February 05, 2009 1:06 PM
To: [hidden email]
Subject: LTRIM

Hi,

I have a Student ID field which has been combined with a Program ID
field.
I need to remove the first 8 characters which is the Student's ID.  For
some
reason it's removing the last 8 characters instead as if I was using
RTRIM.
 Any help would be appreciated.

example of field:

0516895*ACC.ENTR.BAC


This is what I'm using:

DATASET ACTIVATE DataSet1.
COMPUTE newPID=LTRIM(newPROGID,"8").
EXECUTE.


Thanks,

Michelle

=====================
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: LTRIM

Oliver, Richard
In reply to this post by subscribe SPSSX-l Anonymous-2
Your code will remove all leading instances of the number 8. LTRIM isn't the function you want. You want SUBSTR:

compute newPID=substr(newPROGID, 9).

This will ignore the first 8 characters of newPROGID. If you're using version 16 or later, use CHAR.SUBSTR. Also note that if newPID doesn't already exist, you must first declare the new string variable, as in:

string newPID (a10).

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Michelle
Sent: Thursday, February 05, 2009 1:06 PM
To: [hidden email]
Subject: LTRIM

Hi,

I have a Student ID field which has been combined with a Program ID field.
I need to remove the first 8 characters which is the Student's ID.  For some
reason it's removing the last 8 characters instead as if I was using RTRIM.
 Any help would be appreciated.

example of field:

0516895*ACC.ENTR.BAC


This is what I'm using:

DATASET ACTIVATE DataSet1.
COMPUTE newPID=LTRIM(newPROGID,"8").
EXECUTE.


Thanks,

Michelle

=====================
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: LTRIM

Oliver, Richard
In reply to this post by Marks, Jim
The ",29" shouldn't be necessary, unless you only want a portion of what comes after the student id.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marks, Jim
Sent: Thursday, February 05, 2009 4:02 PM
To: [hidden email]
Subject: Re: LTRIM

Michelle:

LTRIM removes leading blanks.

Try (not tested):

DATASET ACTIVATE DataSet1.
STRING newPID (a20).
COMPUTE newPID=SUBSTR(newPROGID,9,29).
EXECUTE.

--jim


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Michelle
Sent: Thursday, February 05, 2009 1:06 PM
To: [hidden email]
Subject: LTRIM

Hi,

I have a Student ID field which has been combined with a Program ID
field.
I need to remove the first 8 characters which is the Student's ID.  For
some
reason it's removing the last 8 characters instead as if I was using
RTRIM.
 Any help would be appreciated.

example of field:

0516895*ACC.ENTR.BAC


This is what I'm using:

DATASET ACTIVATE DataSet1.
COMPUTE newPID=LTRIM(newPROGID,"8").
EXECUTE.


Thanks,

Michelle

=====================
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

=====================
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