|
I have a data set with two different dates - date1 and date2 (both in
ADATE10 format). I need to see how many in how many records date1 and date2 is less that 02/28/2006 and in how many records date1 and date2 is less than 03/31/2007. Using an IF statement (IF fte_3mnth_delq_dt <=2006/02/28) is not getting any results. I'd appreciate any suggestions that you might have. Thanks |
|
Hi Nandini,
Try the code below (which you'll need to edit specific to your dataset, and which also assumes there are no missing values for your date fields); COMPUTE x = (date1 < DATE.MDY(2,28,2006) AND date1 < DATE.MDY(2,28,2006)). COMPUTE y = (date1 < DATE.MDY(3,31,2007) AND date1 < DATE.MDY(3,31,2007)). VALUE LABELS x 0 'Not Earlier than Feb. 28, 2006' 1 'Earlier than Feb. 28, 2006' /y 0 'Not Earlier than March 31, 2007' 1 'Earlier than March 31, 2007'. FREQ x y. I hope that helps, John Norton SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Nandini Sent: Tuesday, May 22, 2007 1:21 PM To: [hidden email] Subject: [BULK] Date Difference Importance: Low I have a data set with two different dates - date1 and date2 (both in ADATE10 format). I need to see how many in how many records date1 and date2 is less that 02/28/2006 and in how many records date1 and date2 is less than 03/31/2007. Using an IF statement (IF fte_3mnth_delq_dt <=2006/02/28) is not getting any results. I'd appreciate any suggestions that you might have. Thanks |
|
In reply to this post by Nandini-2
At 02:20 PM 5/22/2007, Nandini wrote:
>I have a data set with two different dates - date1 and date2 (both in >ADATE10 format). I need to see how many in how many records date1 and >date2 is less that 02/28/2006 and in how many records date1 and date2 >is less than 03/31/2007. > >Using an IF statement (IF fte_3mnth_delq_dt <=2006/02/28) is not >getting any results. See John Norton's fix, of course. The key point is, SPSS does not have date constants (more's the pity). The expression "2006/02/28" is the arithmetic expression (2006/2)/28=1003/28=35.82142857. As per what John said, the only (reasonable) way to get a date value is to build it from the date functions. For the date 2006/02/28, use DATE.MDY(02,28,2006). (SPSS doesn't have DATE.YMD, a minor but sometimes annoying omission.) So, for your IF statement, use IF fte_3mnth_delq_dt <=DATE.MDY(02,28,2006) By the way, dates are numeric variables, and as for all numeric variable, comparison does not in any way depend on what their formats are. Going beyond that, you may want a single variable for your tests. Logic like this (not tested): NUMERIC DateCats (F2). VAR LABEL DateCats 'Range for date1 & date2'. VAR LABEL DateCats 1 'Both <02/28/2006' 2 'Both <03/31/2007' 3 'One >=03/31/2007'. COMPUTE DateCats = 3. IF MIN(date1,date2) < DATE.MDY(03,31,2007) DateCats = 2. IF MIN(date1,date2) < DATE.MDY(02,28,2006) DateCats = 1. FREQUENCIES DateCats. |
| Free forum by Nabble | Edit this page |
