Hi everyone!
I have the following variables: DOE Month 22/07/2013 6 24/08/2013 3 24/05/2013 4 10/09/2013 2 10/06/2013 3 13/02/2013 1 13/02/2013 5 15/12/2013 7 19/02/2013 14 19/11/2013 10 and I would like to know if it's possible to subtract the month from the DOE. I would like to get the following format: DOE_subtracted 22/01/2013 24/05/2013 24/01/2013 10/07/2013 10/03/2013 13/01/2013 13/09/2012 15/05/2013 19/12/2011 19/01/2013 Please, let me know if anything is unclear. Thanks in advance.
mils
|
Administrator
|
See XDATE. and DATE. functions in the Syntax Reference.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
NUMERIC newdate(EDATE). COMPUTE #newmo=XDATE.MONTH(DOE)- MOD(Month,12) . COMPUTE newdate =DATE.MDY(#newmo+(#newmo LE 0)*12, XDATE.MDAY(DOE), XDATE.YEAR(DOE) - TRUNC(Month/12)-(#newmo LE 0)).
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by David Marso
mils wrote (though it doesn't see to have gone out to the list),
>I have the following variables: > >DOE Month >22/07/2013 6 >24/08/2013 3 >24/05/2013 4 >10/09/2013 2 >10/06/2013 3 >13/02/2013 1 >13/02/2013 5 >15/12/2013 7 >19/02/2013 14 >19/11/2013 10 > >and I would like to know if it's possible to subtract the month from the DOE. First of all, you want your dates to be SPSS date values, and they aren't -- there's no format that will display SPSS dates as dd/mm/yyyy. Format EDATE will display them as dd.mm.yyyy, so I'm reading your values into SPSS date values using that format. Your input values, read as EDATE and printed with LIST, look like this: |-----------------------------|---------------------------| |Output Created |24-JUN-2014 16:05:42 | |-----------------------------|---------------------------| DOE Month 22.07.2013 6 24.08.2013 3 24.05.2013 4 10.09.2013 2 10.06.2013 3 13.02.2013 1 13.02.2013 5 15.12.2013 7 19.02.2013 14 19.11.2013 10 Number of cases read: 10 Number of cases listed: 10 David Marso suggested you look at XDATE. and DATE. functions. You should, indeed, know these, but for your problem the DATESUMM function is probably easier. Like this: NUMERIC DOEminus (EDATE10). COMPUTE DOEminus=DATESUMM(DOE,-Month,"Month"). LIST. List |-----------------------------|---------------------------| |Output Created |24-JUN-2014 16:05:42 | |-----------------------------|---------------------------| DOE Month DOEminus 22.07.2013 6 22.01.2013 24.08.2013 3 24.05.2013 24.05.2013 4 24.01.2013 10.09.2013 2 10.07.2013 10.06.2013 3 10.03.2013 13.02.2013 1 13.01.2013 13.02.2013 5 13.09.2012 15.12.2013 7 15.05.2013 19.02.2013 14 19.12.2011 19.11.2013 10 19.01.2013 Number of cases read: 10 Number of cases listed: 10 ================================ APPENDIX: Test data and all code ================================ DATA LIST LIST/ DOE Month (EDATE10, F3). BEGIN DATA 22/07/2013 6 24/08/2013 3 24/05/2013 4 10/09/2013 2 10/06/2013 3 13/02/2013 1 13/02/2013 5 15/12/2013 7 19/02/2013 14 19/11/2013 10 END DATA. LIST. NUMERIC DOEminus (EDATE10). COMPUTE DOEminus=DATESUMM(DOE,-Month,"Month"). LIST. ===================== 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 |
I did a search for "DATESUMM" in the CSR and got zero hits?? Neither nothing on good ol' Google?
Is there any documentation for this mysterious function? And how it differs from DATESUM (if any)? |
Administrator
|
I couldn't find DateSummationSensation anywhere either ;-)
I think Richard may have fat fingered the post. ----------------- data list / d (ADATE). begin data 10/12/2000 end data. compute dd=DateSummationSensation(d,-1,'month'). FORMATS dd (adate). list.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Missed that too. It's not recognized in autocompletion nor in syntax highlight.
Interestingly it works with COMPUTE DOEminus = DATES(DOE, -Month, "Month").Probably minimum characters needed to find function... /PR |
Free forum by Nabble | Edit this page |