How to pad strings in ver 16.0

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

How to pad strings in ver 16.0

Roberts, Michael
Hi Listers,

Has anyone had any difficulty padding strings in Ver. 16.0?  The new
coding syntax: char.lpad(var1,length[,paddingcharacter]), does not seem
to work for me.  However, when I revert to using the older syntax:
lpad(var1, length, paddingchar) it works!  Any ideas on what is going
on?

Thanks in Adavnce

Mike

=====================
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 pad strings in ver 16.0

Oliver, Richard
This seems to work as expected:

data list free /stringvar (a10).
begin data
a b c
end data.
string lpadvar charlpadvar (a10).
compute charlpadvar=char.lpad(rtrim(stringvar), 5, 'x').
compute lpadvar=lpad(rtrim(stringvar), 5, 'x').
list.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Roberts, Michael
Sent: Monday, February 11, 2008 10:51 AM
To: [hidden email]
Subject: How to pad strings in ver 16.0

Hi Listers,

Has anyone had any difficulty padding strings in Ver. 16.0?  The new
coding syntax: char.lpad(var1,length[,paddingcharacter]), does not seem
to work for me.  However, when I revert to using the older syntax:
lpad(var1, length, paddingchar) it works!  Any ideas on what is going
on?

Thanks in Adavnce

Mike

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