Syntax question

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

Syntax question

stace swayne
Dear list,

  I have a data set with the years 1990 through 2006, I would like to select the years 1996 through 2000 and I'm not sure how to write the syntax.

  All suggestions are welcomed.

  Thanks


---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax question

Carlos Renato-2
Dear Friend

Use this syntax to solve your doubt.

RECODE
 Your_Year_Variable
 (1996 thru 2000=1)  (ELSE=0)  INTO  filter .
EXECUTE .
FILTER OFF.
USE ALL.
SELECT IF(NOT(filter =0)).
EXECUTE .

Carlos Renato
Statistician
Recife-PE-Brazil


2007/2/5, stace swayne <[hidden email]>:

> Dear list,
>
>  I have a data set with the years 1990 through 2006, I would like to select the years 1996 through 2000 and I'm not sure how to write the syntax.
>
>  All suggestions are welcomed.
>
>  Thanks
>
>
> ---------------------------------
> No need to miss a message. Get email on-the-go
> with Yahoo! Mail for Mobile. Get started.
>
Reply | Threaded
Open this post in threaded view
|

Re: Syntax question

John Norton
In reply to this post by stace swayne
Hi Stace,
 
Assuming that your date filed is properly defined as a date (and is not a string variable) you can try this:
 
SELECT IF (XDATE.YEAR(year_var) > 1995 AND XDATE.YEAR(year_var) < 2001).
 
Caution: The SELECT IF statement will remove from your active data file all cases which do not satisfy the selection criteria.  If you save that file over itself, you will lose all unselected cases.
 
HTH,
 
 
John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center
 
(708) 327-3095
[hidden email]
 
"Absence of evidence
      is not evidence of absence"


>>> stace swayne <[hidden email]> 2/5/2007 1:03:16 PM >>>

Dear list,

  I have a data set with the years 1990 through 2006, I would like to select the years 1996 through 2000 and I'm not sure how to write the syntax.

  All suggestions are welcomed.

  Thanks


---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax question

Oliver, Richard
In reply to this post by Carlos Renato-2
That is a bit circuitous and creates a "filter" variable that is then used to delete rather than filter cases. Two alternatives:

*filter instead of delete unselected cases.
compute filterVar=(year_var >= 1990 and year_var <= 2006).
filter by filtervar.

*delete unselected cases.
select if year_var >= 1990 and year_var <= 2006.

If year is a component of a date variable (e.g., mm/dd/yyyy), you can extract the date portion with the XDATE.YEAR function, as in

compute filtervar=(xdate.year(year_var) >= 1990
  and xdate.year(year_var) <= 2006).





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Carlos Renato
Sent: Monday, February 05, 2007 1:30 PM
To: [hidden email]
Subject: Re: Syntax question

Dear Friend

Use this syntax to solve your doubt.

RECODE
 Your_Year_Variable
 (1990 thru 2000=1)  (ELSE=0)  INTO  filter .
EXECUTE .
FILTER OFF.
USE ALL.
SELECT IF(NOT(filter =0)).
EXECUTE .

Carlos Renato
Statistician
Recife-PE-Brazil


2007/2/5, stace swayne <[hidden email]>:

> Dear list,
>
>  I have a data set with the years 1990 through 2006, I would like to select the years 1996 through 2000 and I'm not sure how to write the syntax.
>
>  All suggestions are welcomed.
>
>  Thanks
>
>
> ---------------------------------
> No need to miss a message. Get email on-the-go
> with Yahoo! Mail for Mobile. Get started.
>