Recode syntax

Recode syntax

Post by Elin Sigurdardott » Wed, 16 Jul 2003 04:06:13



Hi My name is Elin and I am working with data with the respondents
year of birth. I need a syntax to tansform theyr year of birth into a
new variable with their age in 2003! Can anyone solve this problem?

Elin Sigurdardottir

 
 
 

Recode syntax

Post by Elin Sigurdardott » Wed, 16 Jul 2003 04:06:31


Hi My name is Elin and I am working with data with the respondents
year of birth. I need a syntax to tansform theyr year of birth into a
new variable with their age in 2003! Can anyone solve this problem?

Elin Sigurdardottir

 
 
 

Recode syntax

Post by Drag » Wed, 16 Jul 2003 05:13:01


This ist just one line:
If you have stored the year of birth in the variable birth f.e.
you can simple create it  that way:

compute agenow=2003-birth.



Quote:> Hi My name is Elin and I am working with data with the respondents
> year of birth. I need a syntax to tansform theyr year of birth into a
> new variable with their age in 2003! Can anyone solve this problem?

> Elin Sigurdardottir

 
 
 

Recode syntax

Post by Bruce Weave » Wed, 16 Jul 2003 06:08:12



> This ist just one line:
> If you have stored the year of birth in the variable birth f.e.
> you can simple create it  that way:

> compute agenow=2003-birth.



>>Hi My name is Elin and I am working with data with the respondents
>>year of birth. I need a syntax to tansform theyr year of birth into a
>>new variable with their age in 2003! Can anyone solve this problem?

>>Elin Sigurdardottir

Hi Elin.  It's a little more comlicated than Drago suggests.
  Here are a couple examples:

http://www.angelfire.com/wv/bwhomedir/spss/age.SPS
http://www.angelfire.com/wv/bwhomedir/spss/Art_Kendall_age_computatio...

Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/

 
 
 

Recode syntax

Post by Fre » Wed, 16 Jul 2003 20:18:59


Here are a couple of ways to do it, the problem you may face is that
you need the date of birth, not just the year of birth, as obvioulsy,
you can be born on the 1 Jan, and the 31 Dec of the same year, and not
be the same age.

* Macro to generate a persons age on any given date.

set mprints on.
DEFINE !AGE (!pos !charend ('/')
        /!pos !charend ('/')
        /!pos !charend ('/')).

DO IF ( XDATE.MONTH(Date of Birth) LT !2).
+  COMPUTE AGE= !3-XDATE.YEAR(Date of Birth).
+  ELSE IF XDATE.MDAY(Date of Birth) LE !1 AND XDATE.MONTH(Date of
Birth) = !2.
+  COMPUTE AGE=!3- XDATE.YEAR(Date of Birth).
+  ELSE.
+  COMPUTE AGE=(!3 -1) - XDATE.YEAR(Date of Birth).
END IF.

!ENDDEFINE.

*To run the macro type !age plus the date in the format dd/mm/yyyy, eg

* !AGE 31/08/2002.
* !AGE 19/02/2001.

Or an alternative way

DEFINE !AGE (!pos !charend ('/')
        /!pos !charend ('/')
        /!pos !charend ('/')).

COMPUTE AGE= !3-XDATE.YEAR(Date of Birth).
if date.dmy(xdate.mday(Date of Birth), xdate.month(Date of
Birth),2000) gt date.dmy(!1, !2,2000) AGE=AGE-1.

!ENDDEFINE.



> > This ist just one line:
> > If you have stored the year of birth in the variable birth f.e.
> > you can simple create it  that way:

> > compute agenow=2003-birth.



> >>Hi My name is Elin and I am working with data with the respondents
> >>year of birth. I need a syntax to tansform theyr year of birth into a
> >>new variable with their age in 2003! Can anyone solve this problem?

> >>Elin Sigurdardottir

> Hi Elin.  It's a little more comlicated than Drago suggests.
>   Here are a couple examples:

> http://www.angelfire.com/wv/bwhomedir/spss/age.SPS
> http://www.angelfire.com/wv/bwhomedir/spss/Art_Kendall_age_computatio...

> Cheers,
> Bruce

 
 
 

Recode syntax

Post by Mousi » Thu, 17 Jul 2003 18:32:42


Here's how I do it:

Compute
Ctime.Days(Date.DMY(day,month,yyear) - Birthday)/325.25

I just use the compute on the  transform menu and plug in the funtions

Regards

Joanna


Hi My name is Elin and I am working with data with the respondents
year of birth. I need a syntax to tansform theyr year of birth into a
new variable with their age in 2003! Can anyone solve this problem?

Elin Sigurdardottir

 
 
 

Recode syntax

Post by Elin Sigurdardott » Thu, 17 Jul 2003 19:13:38


Hi in my data I only have the year of birth, and i only nead to know
what age the respondents are at the whole year 2003, no more detailes
needed. How can I do that?
Thank you for the many replies!
Elin
 
 
 

Recode syntax

Post by Bruce Weave » Thu, 17 Jul 2003 22:17:28



> Hi in my data I only have the year of birth, and i only nead to know
> what age the respondents are at the whole year 2003, no more detailes
> needed. How can I do that?
> Thank you for the many replies!
> Elin

Hi Elin.  If all you have is year of birth, then i guess
something like this might suffice:

compute age2003 = 2003 - yob.   /* yob = year of bith .
exe.

Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/

 
 
 

Recode syntax

Post by Drag » Sun, 20 Jul 2003 04:03:55


Hey Bruce!
Why didn't you write: Have a look at Drago's posting?
In Germany we have a proverb:

Warum einfach, wenn's auch kompliziert geht.

Cheers,
Drago




> > Hi in my data I only have the year of birth, and i only nead to know
> > what age the respondents are at the whole year 2003, no more detailes
> > needed. How can I do that?
> > Thank you for the many replies!
> > Elin

> Hi Elin.  If all you have is year of birth, then i guess
> something like this might suffice:

> compute age2003 = 2003 - yob. /* yob = year of bith .
> exe.

> Cheers,
> Bruce
> --
> Bruce Weaver

> www.angelfire.com/wv/bwhomedir/

 
 
 

Recode syntax

Post by Bruce Weave » Sun, 20 Jul 2003 04:24:25



> Hey Bruce!
> Why didn't you write: Have a look at Drago's posting?
> In Germany we have a proverb:

> Warum einfach, wenn's auch kompliziert geht.

> Cheers,
> Drago

I don't understand the German, but touche.  If I had read
Elin's post more carefully the first time, I would have
noticed that she had YEAR only, and did not care about month
and day.

bw

 
 
 

Recode syntax

Post by Drag » Sun, 20 Jul 2003 04:58:15


O.k. the meaning is something like:
Why simple, if you can solve it in a complicated way.
But i have to admit that your year/month/day solution is very
demanding and gave me a rather good impression about the
real professional possiblities of spss.

Thanks
Drago




> > Hey Bruce!
> > Why didn't you write: Have a look at Drago's posting?
> > In Germany we have a proverb:

> > Warum einfach, wenn's auch kompliziert geht.

> > Cheers,
> > Drago

> I don't understand the German, but touche.  If I had read
> Elin's post more carefully the first time, I would have
> noticed that she had YEAR only, and did not care about month
> and day.

> bw

 
 
 

Recode syntax

Post by Elin Sigurdardott » Sun, 20 Jul 2003 07:21:11


Thank you Bruce that worked out fine...this discussion group has saved
my research ;)

Elin

 
 
 

1. recoding and syntax

Hello, I would like to know if there is anyway to recode variables into a
different variable using two separate variables using syntax or any other
suggestions anyone has.  Here is my problem:  I have a variable 8a, and a
variable 8b.  Variables 8a and 8b have cases with values that are: greater
than 1, 0, and Missing.  I would like to to recode so that if the value of
variable 8a is greater than 1 and variable 8b has a missing value, variable
8b gets a value of 0 rather than missing.  However, if variable 8a is missing
and variable 8b is missing as well, I want variable 8b to remain missing
rather than being assigned a 0.  Can anyone help?

2. SLALOM (13/28) c.be FAQ

3. PHP syntax highlighting and heredoc syntax

4. We have another WINNER

5. syntax errors with vim 5.7 and xml.vim syntax file!

6. Lotusphere 2000 Registration available

7. vim: WEB Syntax / Writing syntax files

8. POP3 Server

9. Old Powerscript Syntax comparison with Current Powerscript Syntax ?

10. Problems recoding CDR's

11. using informat to recode date read as rext?

12. what a mess recoding free form fields

13. recoding language preference for logistic regression