creating new variable

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

creating new variable

Abbas, Zahid RQHR
Hello all,

 

I will appreciate any help with the following:

 

I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.

 

Thanks, Zahid

====================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: creating new variable

ViAnn Beadle
What do you mean when you save X0X 1X1 format? Can you give us an example of
what your data look and what you what them to become.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 12:43 PM
To: [hidden email]
Subject: creating new variable

Hello all,



I will appreciate any help with the following:



I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.



Thanks, Zahid

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

FW: creating new variable

Abbas, Zahid RQHR
In reply to this post by Abbas, Zahid RQHR
-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:56 PM
To: Abbas, Zahid RQHR
Subject: RE: creating new variable

Forward your response to the list--you'll get a variety of different
solutions. Is this one variable read as a string?

-----Original Message-----
From: Abbas, Zahid RQHR [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 12:55 PM
To: ViAnn Beadle
Subject: RE: creating new variable

Here is how many data looks.

S0G 3X0
S3N2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A4T0

I want that all of the data looks like

S0G 3X0
S3N 2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A 4T0

Thanks, Zahid



-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:50 PM
To: Abbas, Zahid RQHR; [hidden email]
Subject: RE: creating new variable

What do you mean when you save X0X 1X1 format? Can you give us an
example of
what your data look and what you what them to become.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 12:43 PM
To: [hidden email]
Subject: creating new variable

Hello all,



I will appreciate any help with the following:



I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.



Thanks, Zahid

=======
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: creating new variable

ViAnn Beadle
Assuming that this is a single string variable, something like the following
should work.

STRING newstring(a6).
COMPUTE newstring=replace(oldstring,' ','').

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 1:00 PM
To: [hidden email]
Subject: FW: creating new variable

-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:56 PM
To: Abbas, Zahid RQHR
Subject: RE: creating new variable

Forward your response to the list--you'll get a variety of different
solutions. Is this one variable read as a string?

-----Original Message-----
From: Abbas, Zahid RQHR [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 12:55 PM
To: ViAnn Beadle
Subject: RE: creating new variable

Here is how many data looks.

S0G 3X0
S3N2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A4T0

I want that all of the data looks like

S0G 3X0
S3N 2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A 4T0

Thanks, Zahid



-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:50 PM
To: Abbas, Zahid RQHR; [hidden email]
Subject: RE: creating new variable

What do you mean when you save X0X 1X1 format? Can you give us an
example of
what your data look and what you what them to become.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 12:43 PM
To: [hidden email]
Subject: creating new variable

Hello all,



I will appreciate any help with the following:



I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.



Thanks, Zahid

=======
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
Reply | Threaded
Open this post in threaded view
|

Re: FW: creating new variable

Marks, Jim
In reply to this post by Abbas, Zahid RQHR
data list list /oldPcode (a7).
begin data
'S0G 3X0'
'S3N2K7'
'S0A 1S0'
'S0A 3C0'
'S0A 3C0'
'S0A4T0'
END DATA.

STRING newPcode (a7).
COMPUTE newPcode = oldPcode.
IF substr(oldPcode,4,1) NE ' '
   newPcode = CONCAT(substr(oldPcode,1,3),' ', SUBSTR(oldPcode,4,3) ).
exe.

-- jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 2:00 PM
To: [hidden email]
Subject: FW: creating new variable

-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:56 PM
To: Abbas, Zahid RQHR
Subject: RE: creating new variable

Forward your response to the list--you'll get a variety of different
solutions. Is this one variable read as a string?

-----Original Message-----
From: Abbas, Zahid RQHR [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 12:55 PM
To: ViAnn Beadle
Subject: RE: creating new variable

Here is how many data looks.

S0G 3X0
S3N2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A4T0

I want that all of the data looks like

S0G 3X0
S3N 2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A 4T0

Thanks, Zahid



-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:50 PM
To: Abbas, Zahid RQHR; [hidden email]
Subject: RE: creating new variable

What do you mean when you save X0X 1X1 format? Can you give us an
example of what your data look and what you what them to become.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 12:43 PM
To: [hidden email]
Subject: creating new variable

Hello all,



I will appreciate any help with the following:



I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.



Thanks, Zahid

=======
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
Reply | Threaded
Open this post in threaded view
|

Re: creating new variable

Abbas, Zahid RQHR
Hi Jim,
I get the following error message

>Error # 4381 in column 70.  Text: .
>The expression ends unexpectedly.
>This command not executed.

Zahid


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Marks, Jim
Sent: November 27, 2007 2:27 PM
To: [hidden email]
Subject: Re: FW: creating new variable

data list list /oldPcode (a7).
begin data
'S0G 3X0'
'S3N2K7'
'S0A 1S0'
'S0A 3C0'
'S0A 3C0'
'S0A4T0'
END DATA.

STRING newPcode (a7).
COMPUTE newPcode = oldPcode.
IF substr(oldPcode,4,1) NE ' '
   newPcode = CONCAT(substr(oldPcode,1,3),' ', SUBSTR(oldPcode,4,3) ).
exe.

-- jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 2:00 PM
To: [hidden email]
Subject: FW: creating new variable

-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:56 PM
To: Abbas, Zahid RQHR
Subject: RE: creating new variable

Forward your response to the list--you'll get a variety of different
solutions. Is this one variable read as a string?

-----Original Message-----
From: Abbas, Zahid RQHR [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 12:55 PM
To: ViAnn Beadle
Subject: RE: creating new variable

Here is how many data looks.

S0G 3X0
S3N2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A4T0

I want that all of the data looks like

S0G 3X0
S3N 2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A 4T0

Thanks, Zahid



-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:50 PM
To: Abbas, Zahid RQHR; [hidden email]
Subject: RE: creating new variable

What do you mean when you save X0X 1X1 format? Can you give us an
example of what your data look and what you what them to become.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 12:43 PM
To: [hidden email]
Subject: creating new variable

Hello all,



I will appreciate any help with the following:



I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.



Thanks, Zahid

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

=====================
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: creating new variable

Marks, Jim
The entire syntax posted works for me.

You should not need the syntax beginning at "DATA LIST" and ending at
"END DATA." (this is sample data for the list to show the code works.)

You will need to change the variable name oldPcode to your variable for
the postal codes in the block beginning with "STRING" and ending with
"exe." to run against your data.

The error messages suggests a "." was left off one of the commands--
probably the exe.

--jim

-----Original Message-----
From: Abbas, Zahid RQHR [mailto:[hidden email]]
Sent: Wednesday, November 28, 2007 9:03 AM
To: Marks, Jim; [hidden email]
Subject: RE: creating new variable

Hi Jim,
I get the following error message

>Error # 4381 in column 70.  Text: .
>The expression ends unexpectedly.
>This command not executed.

Zahid


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Marks, Jim
Sent: November 27, 2007 2:27 PM
To: [hidden email]
Subject: Re: FW: creating new variable

data list list /oldPcode (a7).
begin data
'S0G 3X0'
'S3N2K7'
'S0A 1S0'
'S0A 3C0'
'S0A 3C0'
'S0A4T0'
END DATA.

STRING newPcode (a7).
COMPUTE newPcode = oldPcode.
IF substr(oldPcode,4,1) NE ' '
   newPcode = CONCAT(substr(oldPcode,1,3),' ', SUBSTR(oldPcode,4,3) ).
exe.

-- jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 2:00 PM
To: [hidden email]
Subject: FW: creating new variable

-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:56 PM
To: Abbas, Zahid RQHR
Subject: RE: creating new variable

Forward your response to the list--you'll get a variety of different
solutions. Is this one variable read as a string?

-----Original Message-----
From: Abbas, Zahid RQHR [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 12:55 PM
To: ViAnn Beadle
Subject: RE: creating new variable

Here is how many data looks.

S0G 3X0
S3N2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A4T0

I want that all of the data looks like

S0G 3X0
S3N 2K7
S0A 1S0
S0A 3C0
S0A 3C0
S0A 4T0

Thanks, Zahid



-----Original Message-----
From: ViAnn Beadle [mailto:[hidden email]]
Sent: November 27, 2007 1:50 PM
To: Abbas, Zahid RQHR; [hidden email]
Subject: RE: creating new variable

What do you mean when you save X0X 1X1 format? Can you give us an
example of what your data look and what you what them to become.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Abbas, Zahid RQHR
Sent: Tuesday, November 27, 2007 12:43 PM
To: [hidden email]
Subject: creating new variable

Hello all,



I will appreciate any help with the following:



I have a variable where some of the values are in X0X 1X1 and the others
in XOX1X1 format. I want to create a new variable where all values are
in X0X 1X1 format.



Thanks, Zahid

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

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