Combining two variables into a new single variable

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

maelbe
Posts: 3
Joined: Tue Dec 11, 2007 9:28 am

Combining two variables into a new single variable

Postby maelbe » Tue Dec 11, 2007 9:56 am

I am trying to combine two different variables into a new varaible, but has found myself in some difficulty.

My SPSS file contains an extraction information from church records displaying personal info, dates relating to migration and so forth. To sequence the migration dates I created a new variable from the "moving out date." Since this variable is not complete I got a large group of system missing. I would, however, like to replace system missing with info from variable "moving in date." As displayed below, I am missing info from Moving out date 3) and would like to know how I can insert Moving in date 3) which is 31.12.1851 replacing system missing in the former.

Moving out dates
1) 10.12.1853
2) 01.01.1852
3) .
4) 01.01.1856
5) 01.01.1858

Moving out dates
1) .
2) 31.12.1852
3) 31.12.1851
4) 31.12.1856
5) .

I might add that it is impossible for me to do this manually since my file contains up to 35 000 individuals.

I´d appriciate any advice I can get.
Smash
Moderator
Posts: 233
Joined: Tue Aug 07, 2007 11:48 am

Postby Smash » Tue Dec 11, 2007 10:40 am

Conditional compute using if, in syntax it looks like:

Code: Select all

if (sysmis(moving out date)) moving out date=moving in date.
exec.
maelbe
Posts: 3
Joined: Tue Dec 11, 2007 9:28 am

Postby maelbe » Tue Dec 11, 2007 3:46 pm

Well...it is not working, or rather I cannot get it to work. Not even my supervisor could get heads or tails from it...if you can, please explain it to me like I am five...step by step...
Smash
Moderator
Posts: 233
Joined: Tue Aug 07, 2007 11:48 am

Postby Smash » Tue Dec 11, 2007 4:49 pm

Transform > Compute Var > If...
select Includes if case satisfies condition
select SYSMIS(moving out date)*

*SYSMIS(numvar). Logical. Returns 1 or true if the value of numvar is system-missing. The argument numvar must be the name of a numeric variable in the working data file.

click continue
put as Target Variable - moving out date
as Numeric Expression - moving in date
click ok.

I'd like to ask additional question, in case if it really does not work.
What is a format of both variables - data or string ?
Are the sysmis system missing or user define missing (this is important difference)? If variables are strings, for sure it is not a sysmis.
What SPSS version ?
maelbe
Posts: 3
Joined: Tue Dec 11, 2007 9:28 am

Postby maelbe » Wed Dec 12, 2007 9:34 am

You´re a life saver. Thanks. I realized that my mistace was not adding the target value within the brackets following the sysmis. But once I did, it all came into place...
Thanks again... :)
sakuradxb
Posts: 5
Joined: Fri Dec 14, 2007 2:08 pm

Postby sakuradxb » Sat Dec 15, 2007 9:09 am

that's good to know....

:D it's really helpful. i haven't tried it before

Who is online

Users browsing this forum: No registered users and 2 guests

cron