|
Just a picky technical point: it's the number of seconds since the day before 10/15/1582. 10/15/82 is represented internally as 86400, the number of seconds in one day. We refer to the start date for dates as 10/14/1582, but that date doesn't actually exist in the Gregorian calendar, but we thought it would be even more confusing to refer to at as the number of seconds since October 4, 1582.
________________________________ From: SPSSX(r) Discussion on behalf of ViAnn Beadle Sent: Wed 9/5/2007 7:12 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) OK, I as Richard pointed out in another email, misremembered the results of YRMODA--sorry about that. Your date is being calculated as the number of seconds after 12:00 AM 10/15/1582. Nothing comes to mind for getting a true date from these data with the version of SPSS you are using. Now if your original data were in a database and somebody wrote them out as a text with a date format using delimiters, you'd have a chance. Given the archaic version of SPSS sounds to me like the state of Arizona is stuck back in the 70s when it comes to IT. -----Original Message----- From: Ornelas, Fermin [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 3:30 PM To: Richard Ristow; ViAnn Beadle; [hidden email] Subject: RE: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
In reply to this post by Ornelas, Fermin
There is example syntax below the sig block.
I checked this syntax against version 3 manual and the date functions are there. But my VAX is offline at the moment. It runs under v15 date.dmy(day,mnth,year). produces a date based on seconds, i.e. a SPSS internal date. Save all your current work, then open a new instance of SPSS. Cut-and-paste then run the syntax. Does this do what you want? If not please restate your question in more detail. Hope this helps. Art Kendall Social Research Consultants *input 8 digit numeric dates. data list list /issdate(f8). begin data 20070720 20070717 20070705 20070711 20070711 20070706 20070705 end data. STRING IDATE (A8). COMPUTE IDATE=STRING(ISSDATE,F8.0). STRING IYEAR (A4). STRING IMNTH (A2). STRING IDAY (A2). COMPUTE IYEAR=SUBSTR(IDATE,1,4). COMPUTE IMNTH=SUBSTR(IDATE,5,2). COMPUTE IDAY =SUBSTR(IDATE,7,2). NUMERIC YEAR (F4.0). COMPUTE YEAR=number(IYEAR,F4). NUMERIC MNTH (F2.0). COMPUTE MNTH= number(IMNTH,F2). NUMERIC DAY (F2.0). COMPUTE DAY = number(IDAY,F2). COMPUTE IDATEF= date.dmy(day,mnth,year). FORMAT ISSDATE(ADATE). FORMAT IDATEF(ADATE). LIST. Ornelas, Fermin wrote: >> Alternatively, can you get your data to a more current version of SPSS? >> > > This is just wishful thinking. We kid around that the tech support > person is already at a nursing home (no pundit intended). > > I have tried some tricks but had no luck. Here is a sample of the > output: > ISSDATE IDATEF > > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > > Actual Dates > 20070720 > 20070717 > 20070705 > 20070711 > 20070711 > 20070706 > 20070705 > > These are not good conversions. The statements follow: > STRING IDATE (A8) > COMPUTE IDATE=STRING(ISSDATE,F8.0) > STRING IYEAR (A4) > STRING IMNTH (A2) > STRING IDAY (A2) > COMPUTE IYEAR=SUBSTR(IDATE,1,4) > COMPUTE IMNTH=SUBSTR(IDATE,5,2) > COMPUTE IDAY =SUBSTR(IDATE,7,2) > NUMERIC YEAR (F4.0) > COMPUTE YEAR=NUMERIC(IYEAR,F4) > NUMERIC MNTH (F2.0) > COMPUTE MNTH=NUMERIC(IMNTH,F2) > NUMERIC DAY (F2.0) > COMPUTE DAY=NUMERIC(IDAY,F2) > COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) > FORMAT ISSDATE(ADATE) > FORMAT IDATEF(ADATE) > > Note that the first format uses the date as it is in the file (yyyymmdd) > > > The MF version is 4.2. > > -----Original Message----- > From: Richard Ristow [mailto:[hidden email]] > Sent: Wednesday, September 05, 2007 2:05 PM > To: ViAnn Beadle; [hidden email] > Cc: Ornelas, Fermin > Subject: Re: Dates and older versions of SPSS (was Question...) > > Addendum - > > At 03:33 PM 9/5/2007, ViAnn Beadle wrote: > > >> What version of SPSS are you talking about? Unless somebody has a >> manual for that version, it's a bit unlikely you'll get the syntax >> that works with that version from this list. >> > > Alternatively, can you get your data to a more current version of SPSS? > > >> The solution really depends upon whether the value is just a number or >> a string. >> >> 1. You'll probably have to split the value into a year variable, month >> variable, and date variable. How you do that depends upon whether >> you're dealing with a string or a number. >> > > Exactly so. So we'd need both that information and the SPSS version, to > help you. > > Ornelas, you also wrote, > > >>> I have two dates formatted as yyyymmdd and yyyymm. >>> > > Are those different variables? If dates formatted both ways can occur > in the same variable, the code becomes a bit trickier. That's > especially so if the value is a number. > > >> 2. Then use the YRMODA function to create a date variable out of it >> and >> 3. use the ADATE format to format that value. >> > > Unfortunately, that pair of suggestions probably won't work. YRMODA > produced a different output from the current SPSS date representation, > and it won't work with ADATE. If your version of SPSS has ADATE and > other modern date formats, you should also have functions DATE.MDY and > DATE.MOYR, and you should use one or both of those. > > > >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >> Of >> Ornelas, Fermin >> Sent: Wednesday, September 05, 2007 11:19 AM >> To: [hidden email] >> Subject: Re: Question on dealing with dates in variables >> >> I am going to tag along this answer/question. >> In my mainframe version I have two dates formatted as yyyymmdd and >> yyyymm. >> (20070605 200706). What I would like is to output these as: >> >> 06/05/07 and 06/01/07 >> >> >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >> Of >> Richard Ristow >> Sent: Wednesday, September 05, 2007 10:02 AM >> To: [hidden email] >> Subject: Re: Question on dealing with dates in variables >> >> At 11:09 AM 9/5/2007, stace swayne had written: >> >> >>> I have a series of variables that are dates, but they are broken >>> >> down >> >>> by var1month, var1year, var2month, var2year,. I would like to >>> >> combine >> >>> the month and year variables into one variable. >>> >> At 12:10 PM 9/5/2007, Florio Arguillas wrote: >> >> >>> Here's one option using the DATE.MOYR function. Submit this sample >>> code. >>> >>> compute month1 = 12. >>> compute month2 = 1. >>> compute year1 = 1998. >>> compute year2 = 1999. >>> execute. >>> >>> COMPUTE month1year1 = DATE.MOYR(month1,year1) . >>> FORMAT month1year1 (moyr). >>> EXECUTE . >>> >> Of the two suggestions, I think this is considerably the preferable. >> Date values in SPSS files should almost always be SPSS-format dates, >> as >> this does. >> >> And, since I haven't said it recently: the EXECUTE statements are not >> necessary, do nothing useful, and may slow processing considerably in >> a >> large file. >> >> -Good luck and good wishes, >> Richard >> >> NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >> CONFIDENTIAL information and is intended only for the use of the >> specific individual(s) to whom it is addressed. It may contain >> information that is privileged and confidential under state and >> federal >> law. This information may be used or disclosed only in accordance >> with >> law, and you may be subject to penalties under law for improper use or >> further disclosure of the information in this e-mail and its >> attachments. If you have received this e-mail in error, please >> immediately notify the person named above by reply e-mail, and then >> delete the original e-mail. Thank you. >> >> >> >> -- >> No virus found in this incoming message. >> Checked by AVG Free Edition. >> Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >> 9/5/2007 2:55 PM >> > > > |
|
In reply to this post by Oliver, Richard
At 10:23 PM 9/5/2007, Oliver, Richard wrote:
>Just a picky technical point: [an SPSS date or date-time value is] the >number of seconds since the day before 10/15/1582. 10/15/82 is >represented internally as 86400, the number of seconds in one day. We >refer to the start date for dates as 10/14/1582, but that date doesn't >actually exist in the Gregorian calendar, but we thought it would be >even more confusing to refer to at as the number of seconds since >October 4, 1582. Thank you! For more on date confusion, see any book dealing with the Armada that Spain sent against England in 1588. |
|
In reply to this post by Fry, Jonathan B.
Jonathan:
Here is the result of these command lines: SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) >Error # 4033 on line 39 in column 15. Text: DATE.YMD >A function name is followed by a decimal point and a function modifier. >However, the modifier is misspelled or invalid. >No further commands will be executed. Error scan continues. My guess is that this function is not available under this version. This is the output when using 86400*yrmoda SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) LIST VARS= ISSDATE IDATE CASEID Format idate (adate) ISSDATE IDATE CASEID 20070702 07/02/2007 00091716 20070730 07/30/2007 00135886 20070720 07/20/2007 00157939 20070720 07/20/2007 00157939 20070702 07/02/2007 00201331 20070706 07/06/2007 00228227 20070702 07/02/2007 00264334 20070702 07/02/2007 00272953 20070717 07/17/2007 00321332 20070717 07/17/2007 00321332 Thank you for all the replies. And yes we may be stuck in the 70's... Moreover, issdate is numeric. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Wednesday, September 05, 2007 6:04 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) YRMODA returns the number of days since 15 Oct 1582, while the date formats expect the number of seconds since the same date. So you can convert YRMODA output to standard date representation by multiplying by 24*60*60, or 86,400. If you have date formats, you probably have date functions as well. So a sequence like this should work. (If not, substitute 86400*YRMODA for DATE.YMD.) COMPUTE #YR = TRUNC(ISSDATE/1E4) COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA = MOD(ISSDATE,1E2) COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) That works because MOD(X,1En) returns the last n decimal digits of an integer, and TRUNC(X/1En) returns all but the last n decimal digits of a number. Jonathan Fry SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Wednesday, September 05, 2007 4:30 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
Fermin,
Actually, I suspect you have the date functions. DATE.YMD is not one of them (my error). They include DATE.MDY and DATE.DMY, which take the same arguments in different order. Jonathan -----Original Message----- From: Ornelas, Fermin [mailto:[hidden email]] Sent: Thursday, September 06, 2007 9:49 AM To: Fry, Jonathan B.; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Jonathan: Here is the result of these command lines: SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) >Error # 4033 on line 39 in column 15. Text: DATE.YMD >A function name is followed by a decimal point and a function modifier. >However, the modifier is misspelled or invalid. >No further commands will be executed. Error scan continues. My guess is that this function is not available under this version. This is the output when using 86400*yrmoda SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) LIST VARS= ISSDATE IDATE CASEID Format idate (adate) ISSDATE IDATE CASEID 20070702 07/02/2007 00091716 20070730 07/30/2007 00135886 20070720 07/20/2007 00157939 20070720 07/20/2007 00157939 20070702 07/02/2007 00201331 20070706 07/06/2007 00228227 20070702 07/02/2007 00264334 20070702 07/02/2007 00272953 20070717 07/17/2007 00321332 20070717 07/17/2007 00321332 Thank you for all the replies. And yes we may be stuck in the 70's... Moreover, issdate is numeric. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Wednesday, September 05, 2007 6:04 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) YRMODA returns the number of days since 15 Oct 1582, while the date formats expect the number of seconds since the same date. So you can convert YRMODA output to standard date representation by multiplying by 24*60*60, or 86,400. If you have date formats, you probably have date functions as well. So a sequence like this should work. (If not, substitute 86400*YRMODA for DATE.YMD.) COMPUTE #YR = TRUNC(ISSDATE/1E4) COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA = MOD(ISSDATE,1E2) COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) That works because MOD(X,1En) returns the last n decimal digits of an integer, and TRUNC(X/1En) returns all but the last n decimal digits of a number. Jonathan Fry SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Wednesday, September 05, 2007 4:30 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
36 0 COMPUTE #YR= TRUNC(ISSDATE/1E4)
37 0 COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) 38 0 COMPUTE #DA= MOD(ISSDATE,1E2) 39 0 COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) 40 0 LIST VARS= ISSDATE IDATE CASEID There are 2,901,288 bytes of memory available. The largest contiguous area has 2,894,480 bytes. 379 bytes of memory required for the LIST procedure. 280 bytes have already been acquired. 99 bytes remain to be acquired. >Warning # 613 >One of the arguments to the DATE function is out of range or is not an >integer. The result has been set to the system-missing value. But still I get an error... -----Original Message----- From: Fry, Jonathan B. [mailto:[hidden email]] Sent: Thursday, September 06, 2007 8:24 AM To: Ornelas, Fermin; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Fermin, Actually, I suspect you have the date functions. DATE.YMD is not one of them (my error). They include DATE.MDY and DATE.DMY, which take the same arguments in different order. Jonathan -----Original Message----- From: Ornelas, Fermin [mailto:[hidden email]] Sent: Thursday, September 06, 2007 9:49 AM To: Fry, Jonathan B.; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Jonathan: Here is the result of these command lines: SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) >Error # 4033 on line 39 in column 15. Text: DATE.YMD >A function name is followed by a decimal point and a function modifier. >However, the modifier is misspelled or invalid. >No further commands will be executed. Error scan continues. My guess is that this function is not available under this version. This is the output when using 86400*yrmoda SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) LIST VARS= ISSDATE IDATE CASEID Format idate (adate) ISSDATE IDATE CASEID 20070702 07/02/2007 00091716 20070730 07/30/2007 00135886 20070720 07/20/2007 00157939 20070720 07/20/2007 00157939 20070702 07/02/2007 00201331 20070706 07/06/2007 00228227 20070702 07/02/2007 00264334 20070702 07/02/2007 00272953 20070717 07/17/2007 00321332 20070717 07/17/2007 00321332 Thank you for all the replies. And yes we may be stuck in the 70's... Moreover, issdate is numeric. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Wednesday, September 05, 2007 6:04 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) YRMODA returns the number of days since 15 Oct 1582, while the date formats expect the number of seconds since the same date. So you can convert YRMODA output to standard date representation by multiplying by 24*60*60, or 86,400. If you have date formats, you probably have date functions as well. So a sequence like this should work. (If not, substitute 86400*YRMODA for DATE.YMD.) COMPUTE #YR = TRUNC(ISSDATE/1E4) COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA = MOD(ISSDATE,1E2) COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) That works because MOD(X,1En) returns the last n decimal digits of an integer, and TRUNC(X/1En) returns all but the last n decimal digits of a number. Jonathan Fry SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Wednesday, September 05, 2007 4:30 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
Fermin,
you have to rearrange your arguments because you are using a different date function. Instead of: COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) your arguments should be: COMPUTE IDATE=DATE.MDY(#MO,#DA,#YR) Florio At 11:39 AM 9/6/2007, Ornelas, Fermin wrote: > 36 0 COMPUTE #YR= TRUNC(ISSDATE/1E4) > > 37 0 COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) > > 38 0 COMPUTE #DA= MOD(ISSDATE,1E2) > > 39 0 COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) > > 40 0 LIST VARS= ISSDATE IDATE CASEID > >There are 2,901,288 bytes of memory available. > >The largest contiguous area has 2,894,480 bytes. > >379 bytes of memory required for the LIST procedure. > >280 bytes have already been acquired. > >99 bytes remain to be acquired. > > >Warning # 613 > > >One of the arguments to the DATE function is out of range or is not an > > >integer. The result has been set to the system-missing value. > >But still I get an error... > > >-----Original Message----- >From: Fry, Jonathan B. [mailto:[hidden email]] >Sent: Thursday, September 06, 2007 8:24 AM >To: Ornelas, Fermin; [hidden email] >Subject: RE: Re: Dates and older versions of SPSS (was Question...) > >Fermin, > >Actually, I suspect you have the date functions. DATE.YMD is not one of >them (my error). They include DATE.MDY and DATE.DMY, which take the >same arguments in different order. > >Jonathan > >-----Original Message----- >From: Ornelas, Fermin [mailto:[hidden email]] >Sent: Thursday, September 06, 2007 9:49 AM >To: Fry, Jonathan B.; [hidden email] >Subject: RE: Re: Dates and older versions of SPSS (was Question...) > >Jonathan: > >Here is the result of these command lines: > > > SEL IF (ISSTYPE EQ 'PX') > COMPUTE #YR= TRUNC(ISSDATE/1E4) > COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) > COMPUTE #DA= MOD(ISSDATE,1E2) > COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) > >Error # 4033 on line 39 in column 15. Text: DATE.YMD > > >A function name is followed by a decimal point and a function modifier. > > >However, the modifier is misspelled or invalid. > > >No further commands will be executed. Error scan continues. > >My guess is that this function is not available under this version. > >This is the output when using 86400*yrmoda > > SEL IF (ISSTYPE EQ 'PX') > COMPUTE #YR= TRUNC(ISSDATE/1E4) > COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) > COMPUTE #DA= MOD(ISSDATE,1E2) > COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) > LIST VARS= ISSDATE IDATE CASEID > Format idate (adate) > > ISSDATE IDATE CASEID > >20070702 07/02/2007 00091716 >20070730 07/30/2007 00135886 >20070720 07/20/2007 00157939 >20070720 07/20/2007 00157939 >20070702 07/02/2007 00201331 >20070706 07/06/2007 00228227 >20070702 07/02/2007 00264334 >20070702 07/02/2007 00272953 >20070717 07/17/2007 00321332 >20070717 07/17/2007 00321332 > > Thank you for all the replies. > >And yes we may be stuck in the 70's... Moreover, issdate is numeric. > > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >Fry, Jonathan B. >Sent: Wednesday, September 05, 2007 6:04 PM >To: [hidden email] >Subject: Re: Dates and older versions of SPSS (was Question...) > >YRMODA returns the number of days since 15 Oct 1582, while the date >formats expect the number of seconds since the same date. So you can >convert YRMODA output to standard date representation by multiplying by >24*60*60, or 86,400. > >If you have date formats, you probably have date functions as well. So >a sequence like this should work. (If not, substitute 86400*YRMODA for >DATE.YMD.) > >COMPUTE #YR = TRUNC(ISSDATE/1E4) >COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) >COMPUTE #DA = MOD(ISSDATE,1E2) >COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) > >That works because > > MOD(X,1En) returns the last n decimal digits of an integer, and > TRUNC(X/1En) returns all but the last n decimal digits of a >number. > >Jonathan Fry >SPSS Inc. > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 4:30 PM >To: [hidden email] >Subject: Re: Dates and older versions of SPSS (was Question...) > > >Alternatively, can you get your data to a more current version of SPSS? > >This is just wishful thinking. We kid around that the tech support >person is already at a nursing home (no pundit intended). > >I have tried some tricks but had no luck. Here is a sample of the >output: > ISSDATE IDATEF > > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > >Actual Dates >20070720 >20070717 >20070705 >20070711 >20070711 >20070706 >20070705 > >These are not good conversions. The statements follow: >STRING IDATE (A8) >COMPUTE IDATE=STRING(ISSDATE,F8.0) >STRING IYEAR (A4) >STRING IMNTH (A2) >STRING IDAY (A2) >COMPUTE IYEAR=SUBSTR(IDATE,1,4) >COMPUTE IMNTH=SUBSTR(IDATE,5,2) >COMPUTE IDAY =SUBSTR(IDATE,7,2) >NUMERIC YEAR (F4.0) >COMPUTE YEAR=NUMERIC(IYEAR,F4) >NUMERIC MNTH (F2.0) >COMPUTE MNTH=NUMERIC(IMNTH,F2) >NUMERIC DAY (F2.0) >COMPUTE DAY=NUMERIC(IDAY,F2) >COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) >FORMAT ISSDATE(ADATE) >FORMAT IDATEF(ADATE) > >Note that the first format uses the date as it is in the file (yyyymmdd) > > >The MF version is 4.2. > >-----Original Message----- >From: Richard Ristow [mailto:[hidden email]] >Sent: Wednesday, September 05, 2007 2:05 PM >To: ViAnn Beadle; [hidden email] >Cc: Ornelas, Fermin >Subject: Re: Dates and older versions of SPSS (was Question...) > >Addendum - > >At 03:33 PM 9/5/2007, ViAnn Beadle wrote: > > >What version of SPSS are you talking about? Unless somebody has a > >manual for that version, it's a bit unlikely you'll get the syntax > >that works with that version from this list. > >Alternatively, can you get your data to a more current version of SPSS? > > >The solution really depends upon whether the value is just a number or > >a string. > > > >1. You'll probably have to split the value into a year variable, month > >variable, and date variable. How you do that depends upon whether > >you're dealing with a string or a number. > >Exactly so. So we'd need both that information and the SPSS version, to >help you. > >Ornelas, you also wrote, > > >>I have two dates formatted as yyyymmdd and yyyymm. > >Are those different variables? If dates formatted both ways can occur >in the same variable, the code becomes a bit trickier. That's >especially so if the value is a number. > > >2. Then use the YRMODA function to create a date variable out of it > >and > >3. use the ADATE format to format that value. > >Unfortunately, that pair of suggestions probably won't work. YRMODA >produced a different output from the current SPSS date representation, >and it won't work with ADATE. If your version of SPSS has ADATE and >other modern date formats, you should also have functions DATE.MDY and >DATE.MOYR, and you should use one or both of those. > > > >-----Original Message----- > >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > >Of > >Ornelas, Fermin > >Sent: Wednesday, September 05, 2007 11:19 AM > >To: [hidden email] > >Subject: Re: Question on dealing with dates in variables > > > >I am going to tag along this answer/question. > >In my mainframe version I have two dates formatted as yyyymmdd and > >yyyymm. > >(20070605 200706). What I would like is to output these as: > > > >06/05/07 and 06/01/07 > > > > > >-----Original Message----- > >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > >Of > >Richard Ristow > >Sent: Wednesday, September 05, 2007 10:02 AM > >To: [hidden email] > >Subject: Re: Question on dealing with dates in variables > > > >At 11:09 AM 9/5/2007, stace swayne had written: > > > > >I have a series of variables that are dates, but they are broken > > down > > >by var1month, var1year, var2month, var2year,. I would like to > > combine > > >the month and year variables into one variable. > > > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > > > >Here's one option using the DATE.MOYR function. Submit this sample > > >code. > > > > > >compute month1 = 12. > > >compute month2 = 1. > > >compute year1 = 1998. > > >compute year2 = 1999. > > >execute. > > > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > > >FORMAT month1year1 (moyr). > > >EXECUTE . > > > >Of the two suggestions, I think this is considerably the preferable. > >Date values in SPSS files should almost always be SPSS-format dates, > >as > >this does. > > > >And, since I haven't said it recently: the EXECUTE statements are not > >necessary, do nothing useful, and may slow processing considerably in > >a > >large file. > > > >-Good luck and good wishes, > > Richard > > > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR > >CONFIDENTIAL information and is intended only for the use of the > >specific individual(s) to whom it is addressed. It may contain > >information that is privileged and confidential under state and > >federal > >law. This information may be used or disclosed only in accordance > >with > >law, and you may be subject to penalties under law for improper use or > >further disclosure of the information in this e-mail and its > >attachments. If you have received this e-mail in error, please > >immediately notify the person named above by reply e-mail, and then > >delete the original e-mail. Thank you. > > > > > > > >-- > >No virus found in this incoming message. > >Checked by AVG Free Edition. > >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: > >9/5/2007 2:55 PM |
|
Yeah, I should have figured this out.
Thanks Florio... -----Original Message----- From: Florio Arguillas [mailto:[hidden email]] Sent: Thursday, September 06, 2007 8:58 AM To: Ornelas, Fermin; [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) Fermin, you have to rearrange your arguments because you are using a different date function. Instead of: COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) your arguments should be: COMPUTE IDATE=DATE.MDY(#MO,#DA,#YR) Florio At 11:39 AM 9/6/2007, Ornelas, Fermin wrote: > 36 0 COMPUTE #YR= TRUNC(ISSDATE/1E4) > > 37 0 COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) > > 38 0 COMPUTE #DA= MOD(ISSDATE,1E2) > > 39 0 COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) > > 40 0 LIST VARS= ISSDATE IDATE CASEID > >There are 2,901,288 bytes of memory available. > >The largest contiguous area has 2,894,480 bytes. > >379 bytes of memory required for the LIST procedure. > >280 bytes have already been acquired. > >99 bytes remain to be acquired. > > >Warning # 613 > > >One of the arguments to the DATE function is out of range or is not > > >integer. The result has been set to the system-missing value. > >But still I get an error... > > >-----Original Message----- >From: Fry, Jonathan B. [mailto:[hidden email]] >Sent: Thursday, September 06, 2007 8:24 AM >To: Ornelas, Fermin; [hidden email] >Subject: RE: Re: Dates and older versions of SPSS (was Question...) > >Fermin, > >Actually, I suspect you have the date functions. DATE.YMD is not one >them (my error). They include DATE.MDY and DATE.DMY, which take the >same arguments in different order. > >Jonathan > >-----Original Message----- >From: Ornelas, Fermin [mailto:[hidden email]] >Sent: Thursday, September 06, 2007 9:49 AM >To: Fry, Jonathan B.; [hidden email] >Subject: RE: Re: Dates and older versions of SPSS (was Question...) > >Jonathan: > >Here is the result of these command lines: > > > SEL IF (ISSTYPE EQ 'PX') > COMPUTE #YR= TRUNC(ISSDATE/1E4) > COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) > COMPUTE #DA= MOD(ISSDATE,1E2) > COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) > >Error # 4033 on line 39 in column 15. Text: DATE.YMD > > >A function name is followed by a decimal point and a function > > >However, the modifier is misspelled or invalid. > > >No further commands will be executed. Error scan continues. > >My guess is that this function is not available under this version. > >This is the output when using 86400*yrmoda > > SEL IF (ISSTYPE EQ 'PX') > COMPUTE #YR= TRUNC(ISSDATE/1E4) > COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) > COMPUTE #DA= MOD(ISSDATE,1E2) > COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) > LIST VARS= ISSDATE IDATE CASEID > Format idate (adate) > > ISSDATE IDATE CASEID > >20070702 07/02/2007 00091716 >20070730 07/30/2007 00135886 >20070720 07/20/2007 00157939 >20070720 07/20/2007 00157939 >20070702 07/02/2007 00201331 >20070706 07/06/2007 00228227 >20070702 07/02/2007 00264334 >20070702 07/02/2007 00272953 >20070717 07/17/2007 00321332 >20070717 07/17/2007 00321332 > > Thank you for all the replies. > >And yes we may be stuck in the 70's... Moreover, issdate is numeric. > > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Fry, Jonathan B. >Sent: Wednesday, September 05, 2007 6:04 PM >To: [hidden email] >Subject: Re: Dates and older versions of SPSS (was Question...) > >YRMODA returns the number of days since 15 Oct 1582, while the date >formats expect the number of seconds since the same date. So you can >convert YRMODA output to standard date representation by multiplying by >24*60*60, or 86,400. > >If you have date formats, you probably have date functions as well. So >a sequence like this should work. (If not, substitute 86400*YRMODA for >DATE.YMD.) > >COMPUTE #YR = TRUNC(ISSDATE/1E4) >COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) >COMPUTE #DA = MOD(ISSDATE,1E2) >COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) > >That works because > > MOD(X,1En) returns the last n decimal digits of an integer, > TRUNC(X/1En) returns all but the last n decimal digits of a >number. > >Jonathan Fry >SPSS Inc. > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 4:30 PM >To: [hidden email] >Subject: Re: Dates and older versions of SPSS (was Question...) > > >Alternatively, can you get your data to a more current version of SPSS? > >This is just wishful thinking. We kid around that the tech support >person is already at a nursing home (no pundit intended). > >I have tried some tricks but had no luck. Here is a sample of the >output: > ISSDATE IDATEF > > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > 06/03/1583 10/15/1582 > >Actual Dates >20070720 >20070717 >20070705 >20070711 >20070711 >20070706 >20070705 > >These are not good conversions. The statements follow: >STRING IDATE (A8) >COMPUTE IDATE=STRING(ISSDATE,F8.0) >STRING IYEAR (A4) >STRING IMNTH (A2) >STRING IDAY (A2) >COMPUTE IYEAR=SUBSTR(IDATE,1,4) >COMPUTE IMNTH=SUBSTR(IDATE,5,2) >COMPUTE IDAY =SUBSTR(IDATE,7,2) >NUMERIC YEAR (F4.0) >COMPUTE YEAR=NUMERIC(IYEAR,F4) >NUMERIC MNTH (F2.0) >COMPUTE MNTH=NUMERIC(IMNTH,F2) >NUMERIC DAY (F2.0) >COMPUTE DAY=NUMERIC(IDAY,F2) >COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) >FORMAT ISSDATE(ADATE) >FORMAT IDATEF(ADATE) > >Note that the first format uses the date as it is in the file > > >The MF version is 4.2. > >-----Original Message----- >From: Richard Ristow [mailto:[hidden email]] >Sent: Wednesday, September 05, 2007 2:05 PM >To: ViAnn Beadle; [hidden email] >Cc: Ornelas, Fermin >Subject: Re: Dates and older versions of SPSS (was Question...) > >Addendum - > >At 03:33 PM 9/5/2007, ViAnn Beadle wrote: > > >What version of SPSS are you talking about? Unless somebody has a > >manual for that version, it's a bit unlikely you'll get the syntax > >that works with that version from this list. > >Alternatively, can you get your data to a more current version of SPSS? > > >The solution really depends upon whether the value is just a number > >a string. > > > >1. You'll probably have to split the value into a year variable, month > >variable, and date variable. How you do that depends upon whether > >you're dealing with a string or a number. > >Exactly so. So we'd need both that information and the SPSS version, to >help you. > >Ornelas, you also wrote, > > >>I have two dates formatted as yyyymmdd and yyyymm. > >Are those different variables? If dates formatted both ways can occur >in the same variable, the code becomes a bit trickier. That's >especially so if the value is a number. > > >2. Then use the YRMODA function to create a date variable out of it > >and > >3. use the ADATE format to format that value. > >Unfortunately, that pair of suggestions probably won't work. YRMODA >produced a different output from the current SPSS date representation, >and it won't work with ADATE. If your version of SPSS has ADATE and >other modern date formats, you should also have functions DATE.MDY and >DATE.MOYR, and you should use one or both of those. > > > >-----Original Message----- > >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > >Of > >Ornelas, Fermin > >Sent: Wednesday, September 05, 2007 11:19 AM > >To: [hidden email] > >Subject: Re: Question on dealing with dates in variables > > > >I am going to tag along this answer/question. > >In my mainframe version I have two dates formatted as yyyymmdd and > >yyyymm. > >(20070605 200706). What I would like is to output these as: > > > >06/05/07 and 06/01/07 > > > > > >-----Original Message----- > >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > >Of > >Richard Ristow > >Sent: Wednesday, September 05, 2007 10:02 AM > >To: [hidden email] > >Subject: Re: Question on dealing with dates in variables > > > >At 11:09 AM 9/5/2007, stace swayne had written: > > > > >I have a series of variables that are dates, but they are broken > > down > > >by var1month, var1year, var2month, var2year,. I would like to > > combine > > >the month and year variables into one variable. > > > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > > > >Here's one option using the DATE.MOYR function. Submit this > > >code. > > > > > >compute month1 = 12. > > >compute month2 = 1. > > >compute year1 = 1998. > > >compute year2 = 1999. > > >execute. > > > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > > >FORMAT month1year1 (moyr). > > >EXECUTE . > > > >Of the two suggestions, I think this is considerably the preferable. > >Date values in SPSS files should almost always be SPSS-format dates, > >as > >this does. > > > >And, since I haven't said it recently: the EXECUTE statements are not > >necessary, do nothing useful, and may slow processing considerably in > >a > >large file. > > > >-Good luck and good wishes, > > Richard > > > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR > >CONFIDENTIAL information and is intended only for the use of the > >specific individual(s) to whom it is addressed. It may contain > >information that is privileged and confidential under state and > >federal > >law. This information may be used or disclosed only in accordance > >with > >law, and you may be subject to penalties under law for improper use > >further disclosure of the information in this e-mail and its > >attachments. If you have received this e-mail in error, please > >immediately notify the person named above by reply e-mail, and then > >delete the original e-mail. Thank you. > > > > > > > >-- > >No virus found in this incoming message. > >Checked by AVG Free Edition. > >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: > >9/5/2007 2:55 PM |
|
In reply to this post by Ornelas, Fermin
DATE.MDY takes arguments month, day, year in that order (hence the name).
Jonathan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Thursday, September 06, 2007 10:39 AM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) 36 0 COMPUTE #YR= TRUNC(ISSDATE/1E4) 37 0 COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) 38 0 COMPUTE #DA= MOD(ISSDATE,1E2) 39 0 COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) 40 0 LIST VARS= ISSDATE IDATE CASEID There are 2,901,288 bytes of memory available. The largest contiguous area has 2,894,480 bytes. 379 bytes of memory required for the LIST procedure. 280 bytes have already been acquired. 99 bytes remain to be acquired. >Warning # 613 >One of the arguments to the DATE function is out of range or is not an >integer. The result has been set to the system-missing value. But still I get an error... -----Original Message----- From: Fry, Jonathan B. [mailto:[hidden email]] Sent: Thursday, September 06, 2007 8:24 AM To: Ornelas, Fermin; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Fermin, Actually, I suspect you have the date functions. DATE.YMD is not one of them (my error). They include DATE.MDY and DATE.DMY, which take the same arguments in different order. Jonathan -----Original Message----- From: Ornelas, Fermin [mailto:[hidden email]] Sent: Thursday, September 06, 2007 9:49 AM To: Fry, Jonathan B.; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Jonathan: Here is the result of these command lines: SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) >Error # 4033 on line 39 in column 15. Text: DATE.YMD >A function name is followed by a decimal point and a function modifier. >However, the modifier is misspelled or invalid. >No further commands will be executed. Error scan continues. My guess is that this function is not available under this version. This is the output when using 86400*yrmoda SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) LIST VARS= ISSDATE IDATE CASEID Format idate (adate) ISSDATE IDATE CASEID 20070702 07/02/2007 00091716 20070730 07/30/2007 00135886 20070720 07/20/2007 00157939 20070720 07/20/2007 00157939 20070702 07/02/2007 00201331 20070706 07/06/2007 00228227 20070702 07/02/2007 00264334 20070702 07/02/2007 00272953 20070717 07/17/2007 00321332 20070717 07/17/2007 00321332 Thank you for all the replies. And yes we may be stuck in the 70's... Moreover, issdate is numeric. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Wednesday, September 05, 2007 6:04 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) YRMODA returns the number of days since 15 Oct 1582, while the date formats expect the number of seconds since the same date. So you can convert YRMODA output to standard date representation by multiplying by 24*60*60, or 86,400. If you have date formats, you probably have date functions as well. So a sequence like this should work. (If not, substitute 86400*YRMODA for DATE.YMD.) COMPUTE #YR = TRUNC(ISSDATE/1E4) COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA = MOD(ISSDATE,1E2) COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) That works because MOD(X,1En) returns the last n decimal digits of an integer, and TRUNC(X/1En) returns all but the last n decimal digits of a number. Jonathan Fry SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Wednesday, September 05, 2007 4:30 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
Yeah, Florio made the point. I rushed w/o thinking.
Thank you, -----Original Message----- From: Fry, Jonathan B. [mailto:[hidden email]] Sent: Thursday, September 06, 2007 9:00 AM To: Ornelas, Fermin; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) DATE.MDY takes arguments month, day, year in that order (hence the name). Jonathan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Thursday, September 06, 2007 10:39 AM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) 36 0 COMPUTE #YR= TRUNC(ISSDATE/1E4) 37 0 COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) 38 0 COMPUTE #DA= MOD(ISSDATE,1E2) 39 0 COMPUTE IDATE=DATE.MDY(#YR,#MO,#DA) 40 0 LIST VARS= ISSDATE IDATE CASEID There are 2,901,288 bytes of memory available. The largest contiguous area has 2,894,480 bytes. 379 bytes of memory required for the LIST procedure. 280 bytes have already been acquired. 99 bytes remain to be acquired. >Warning # 613 >One of the arguments to the DATE function is out of range or is not an >integer. The result has been set to the system-missing value. But still I get an error... -----Original Message----- From: Fry, Jonathan B. [mailto:[hidden email]] Sent: Thursday, September 06, 2007 8:24 AM To: Ornelas, Fermin; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Fermin, Actually, I suspect you have the date functions. DATE.YMD is not one of them (my error). They include DATE.MDY and DATE.DMY, which take the same arguments in different order. Jonathan -----Original Message----- From: Ornelas, Fermin [mailto:[hidden email]] Sent: Thursday, September 06, 2007 9:49 AM To: Fry, Jonathan B.; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Jonathan: Here is the result of these command lines: SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) >Error # 4033 on line 39 in column 15. Text: DATE.YMD >A function name is followed by a decimal point and a function modifier. >However, the modifier is misspelled or invalid. >No further commands will be executed. Error scan continues. My guess is that this function is not available under this version. This is the output when using 86400*yrmoda SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) LIST VARS= ISSDATE IDATE CASEID Format idate (adate) ISSDATE IDATE CASEID 20070702 07/02/2007 00091716 20070730 07/30/2007 00135886 20070720 07/20/2007 00157939 20070720 07/20/2007 00157939 20070702 07/02/2007 00201331 20070706 07/06/2007 00228227 20070702 07/02/2007 00264334 20070702 07/02/2007 00272953 20070717 07/17/2007 00321332 20070717 07/17/2007 00321332 Thank you for all the replies. And yes we may be stuck in the 70's... Moreover, issdate is numeric. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Wednesday, September 05, 2007 6:04 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) YRMODA returns the number of days since 15 Oct 1582, while the date formats expect the number of seconds since the same date. So you can convert YRMODA output to standard date representation by multiplying by 24*60*60, or 86,400. If you have date formats, you probably have date functions as well. So a sequence like this should work. (If not, substitute 86400*YRMODA for DATE.YMD.) COMPUTE #YR = TRUNC(ISSDATE/1E4) COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA = MOD(ISSDATE,1E2) COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) That works because MOD(X,1En) returns the last n decimal digits of an integer, and TRUNC(X/1En) returns all but the last n decimal digits of a number. Jonathan Fry SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Wednesday, September 05, 2007 4:30 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
In reply to this post by Fry, Jonathan B.
Jonathan:
Yes, it is nice to know that. I just corrected my statement and got the expected results Fermin Ornelas -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Thursday, September 06, 2007 8:24 AM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) Fermin, Actually, I suspect you have the date functions. DATE.YMD is not one of them (my error). They include DATE.MDY and DATE.DMY, which take the same arguments in different order. Jonathan -----Original Message----- From: Ornelas, Fermin [mailto:[hidden email]] Sent: Thursday, September 06, 2007 9:49 AM To: Fry, Jonathan B.; [hidden email] Subject: RE: Re: Dates and older versions of SPSS (was Question...) Jonathan: Here is the result of these command lines: SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=DATE.YMD(#YR,#MO,#DA) >Error # 4033 on line 39 in column 15. Text: DATE.YMD >A function name is followed by a decimal point and a function modifier. >However, the modifier is misspelled or invalid. >No further commands will be executed. Error scan continues. My guess is that this function is not available under this version. This is the output when using 86400*yrmoda SEL IF (ISSTYPE EQ 'PX') COMPUTE #YR= TRUNC(ISSDATE/1E4) COMPUTE #MO= TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA= MOD(ISSDATE,1E2) COMPUTE IDATE=86400*YRMODA(#YR,#MO,#DA) LIST VARS= ISSDATE IDATE CASEID Format idate (adate) ISSDATE IDATE CASEID 20070702 07/02/2007 00091716 20070730 07/30/2007 00135886 20070720 07/20/2007 00157939 20070720 07/20/2007 00157939 20070702 07/02/2007 00201331 20070706 07/06/2007 00228227 20070702 07/02/2007 00264334 20070702 07/02/2007 00272953 20070717 07/17/2007 00321332 20070717 07/17/2007 00321332 Thank you for all the replies. And yes we may be stuck in the 70's... Moreover, issdate is numeric. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Fry, Jonathan B. Sent: Wednesday, September 05, 2007 6:04 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) YRMODA returns the number of days since 15 Oct 1582, while the date formats expect the number of seconds since the same date. So you can convert YRMODA output to standard date representation by multiplying by 24*60*60, or 86,400. If you have date formats, you probably have date functions as well. So a sequence like this should work. (If not, substitute 86400*YRMODA for DATE.YMD.) COMPUTE #YR = TRUNC(ISSDATE/1E4) COMPUTE #MO = TRUNC(MOD(ISSDATE,1E4)/1E2) COMPUTE #DA = MOD(ISSDATE,1E2) COMPUTE IDATE = DATE.YMD(#YR,#MO,#DA) That works because MOD(X,1En) returns the last n decimal digits of an integer, and TRUNC(X/1En) returns all but the last n decimal digits of a number. Jonathan Fry SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ornelas, Fermin Sent: Wednesday, September 05, 2007 4:30 PM To: [hidden email] Subject: Re: Dates and older versions of SPSS (was Question...) >Alternatively, can you get your data to a more current version of SPSS? This is just wishful thinking. We kid around that the tech support person is already at a nursing home (no pundit intended). I have tried some tricks but had no luck. Here is a sample of the output: ISSDATE IDATEF 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 06/03/1583 10/15/1582 Actual Dates 20070720 20070717 20070705 20070711 20070711 20070706 20070705 These are not good conversions. The statements follow: STRING IDATE (A8) COMPUTE IDATE=STRING(ISSDATE,F8.0) STRING IYEAR (A4) STRING IMNTH (A2) STRING IDAY (A2) COMPUTE IYEAR=SUBSTR(IDATE,1,4) COMPUTE IMNTH=SUBSTR(IDATE,5,2) COMPUTE IDAY =SUBSTR(IDATE,7,2) NUMERIC YEAR (F4.0) COMPUTE YEAR=NUMERIC(IYEAR,F4) NUMERIC MNTH (F2.0) COMPUTE MNTH=NUMERIC(IMNTH,F2) NUMERIC DAY (F2.0) COMPUTE DAY=NUMERIC(IDAY,F2) COMPUTE IDATEF=YRMODA(YEAR,MNTH,DAY) FORMAT ISSDATE(ADATE) FORMAT IDATEF(ADATE) Note that the first format uses the date as it is in the file (yyyymmdd) The MF version is 4.2. -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Wednesday, September 05, 2007 2:05 PM To: ViAnn Beadle; [hidden email] Cc: Ornelas, Fermin Subject: Re: Dates and older versions of SPSS (was Question...) Addendum - At 03:33 PM 9/5/2007, ViAnn Beadle wrote: >What version of SPSS are you talking about? Unless somebody has a >manual for that version, it's a bit unlikely you'll get the syntax >that works with that version from this list. Alternatively, can you get your data to a more current version of SPSS? >The solution really depends upon whether the value is just a number or >a string. > >1. You'll probably have to split the value into a year variable, month >variable, and date variable. How you do that depends upon whether >you're dealing with a string or a number. Exactly so. So we'd need both that information and the SPSS version, to help you. Ornelas, you also wrote, >>I have two dates formatted as yyyymmdd and yyyymm. Are those different variables? If dates formatted both ways can occur in the same variable, the code becomes a bit trickier. That's especially so if the value is a number. >2. Then use the YRMODA function to create a date variable out of it >and >3. use the ADATE format to format that value. Unfortunately, that pair of suggestions probably won't work. YRMODA produced a different output from the current SPSS date representation, and it won't work with ADATE. If your version of SPSS has ADATE and other modern date formats, you should also have functions DATE.MDY and DATE.MOYR, and you should use one or both of those. >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Ornelas, Fermin >Sent: Wednesday, September 05, 2007 11:19 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >I am going to tag along this answer/question. >In my mainframe version I have two dates formatted as yyyymmdd and >yyyymm. >(20070605 200706). What I would like is to output these as: > >06/05/07 and 06/01/07 > > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >Of >Richard Ristow >Sent: Wednesday, September 05, 2007 10:02 AM >To: [hidden email] >Subject: Re: Question on dealing with dates in variables > >At 11:09 AM 9/5/2007, stace swayne had written: > > >I have a series of variables that are dates, but they are broken > down > >by var1month, var1year, var2month, var2year,. I would like to > combine > >the month and year variables into one variable. > >At 12:10 PM 9/5/2007, Florio Arguillas wrote: > > >Here's one option using the DATE.MOYR function. Submit this sample > >code. > > > >compute month1 = 12. > >compute month2 = 1. > >compute year1 = 1998. > >compute year2 = 1999. > >execute. > > > >COMPUTE month1year1 = DATE.MOYR(month1,year1) . > >FORMAT month1year1 (moyr). > >EXECUTE . > >Of the two suggestions, I think this is considerably the preferable. >Date values in SPSS files should almost always be SPSS-format dates, >as >this does. > >And, since I haven't said it recently: the EXECUTE statements are not >necessary, do nothing useful, and may slow processing considerably in >a >large file. > >-Good luck and good wishes, > Richard > >NOTICE: This e-mail (and any attachments) may contain PRIVILEGED OR >CONFIDENTIAL information and is intended only for the use of the >specific individual(s) to whom it is addressed. It may contain >information that is privileged and confidential under state and >federal >law. This information may be used or disclosed only in accordance >with >law, and you may be subject to penalties under law for improper use or >further disclosure of the information in this e-mail and its >attachments. If you have received this e-mail in error, please >immediately notify the person named above by reply e-mail, and then >delete the original e-mail. Thank you. > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.485 / Virus Database: 269.13.6/991 - Release Date: >9/5/2007 2:55 PM |
|
In reply to this post by Monika Heinzel-Gutenbrunner-2
I had similar problems with charts in older versions of SPSS. It's not
that it wasn't possible to create similar charts, with similar colors, patterns, variables, etc.. The problem I ran into was getting the chart to kick out the exact same size and scale for every one of the charts. I was not able to identify a way to override the "automated" scaling function in chart, thus the maximum and minimum shown on the Y axis was different between charts and had to be changed manually. Do newer versions of SPSS make this easier? On Wed, 5 Sep 2007 09:44:44 +0200, Monika Heinzel-Gutenbrunner <[hidden email]> wrote: >Dear all, > > > >I wonder if GPL offers any possibility of changing the size of lettering >and the gauge of lines (e.g. axes) by means of syntax. We have a number >of graphs that have to be plotted time and again with other data. If the >formatting of axes, lines, lettering and graphs has to be entered >manually by means of the GRAPH EDITOR, it is very time-consuming. Using >templates is of no real help, either. > > > >I would very much appreciate your help. Thank you. > > > >Best regards, > > > >Monika Heinzel-Gutenbrunner |
|
With GPL you can constrain the min/max for scale axes via syntax--GPL was
introduced in Version 14. Using the GRAPH command, you must first create a chart, edit the axis by turning off custom on the min and max values and then save the template specifying only scale range for the scale axes item. Now you can apply that template to subsequent charts. Note that a chart template is just a piece of XML with change specifications in it. It's really important when creating a template to only save those things you've changed. If my test the override node in the template looks like this: <setAxisInterval lowerMapping="exact" max="150000.0" min="10000.0" role="y" upperMapping="exact"/> Because I set the max to 150000, and min to 10000 for the y axis. Note that templates are a bit flaky in older versions of SPSS but work fairly well in 15. However, I'm fairly certain that scale changes like this worked well in earlier versions. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of James Whanger Sent: Sunday, September 09, 2007 9:25 AM To: [hidden email] Subject: Re: syntax for graphics I had similar problems with charts in older versions of SPSS. It's not that it wasn't possible to create similar charts, with similar colors, patterns, variables, etc.. The problem I ran into was getting the chart to kick out the exact same size and scale for every one of the charts. I was not able to identify a way to override the "automated" scaling function in chart, thus the maximum and minimum shown on the Y axis was different between charts and had to be changed manually. Do newer versions of SPSS make this easier? On Wed, 5 Sep 2007 09:44:44 +0200, Monika Heinzel-Gutenbrunner <[hidden email]> wrote: >Dear all, > > > >I wonder if GPL offers any possibility of changing the size of lettering >and the gauge of lines (e.g. axes) by means of syntax. We have a number >of graphs that have to be plotted time and again with other data. If the >formatting of axes, lines, lettering and graphs has to be entered >manually by means of the GRAPH EDITOR, it is very time-consuming. Using >templates is of no real help, either. > > > >I would very much appreciate your help. Thank you. > > > >Best regards, > > > >Monika Heinzel-Gutenbrunner |
|
In reply to this post by James Whanger
I am having a similar problem with SPSS 14. There does not seem to be
much relationahip between the size I specify and what prints. Also, I had no success trying to save a template of the graph. Any suggestions would be greatly appreciated. James Whanger wrote: >I had similar problems with charts in older versions of SPSS. It's not >that it wasn't possible to create similar charts, with similar colors, >patterns, variables, etc.. The problem I ran into was getting the chart >to kick out the exact same size and scale for every one of the charts. I >was not able to identify a way to override the "automated" scaling >function in chart, thus the maximum and minimum shown on the Y axis was >different between charts and had to be changed manually. > >Do newer versions of SPSS make this easier? > >On Wed, 5 Sep 2007 09:44:44 +0200, Monika Heinzel-Gutenbrunner ><[hidden email]> wrote: > > > >>Dear all, >> >> >> >>I wonder if GPL offers any possibility of changing the size of lettering >>and the gauge of lines (e.g. axes) by means of syntax. We have a number >>of graphs that have to be plotted time and again with other data. If the >>formatting of axes, lines, lettering and graphs has to be entered >>manually by means of the GRAPH EDITOR, it is very time-consuming. Using >>templates is of no real help, either. >> >> >> >>I would very much appreciate your help. Thank you. >> >> >> >>Best regards, >> >> >> >>Monika Heinzel-Gutenbrunner >> >> > > > |
|
Size of what? What do you attributes do you check off when you save your
template? You need to provide a lot more information. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Monica Malone Sent: Sunday, September 09, 2007 10:56 AM To: [hidden email] Subject: Re: syntax for graphics I am having a similar problem with SPSS 14. There does not seem to be much relationahip between the size I specify and what prints. Also, I had no success trying to save a template of the graph. Any suggestions would be greatly appreciated. James Whanger wrote: >I had similar problems with charts in older versions of SPSS. It's not >that it wasn't possible to create similar charts, with similar colors, >patterns, variables, etc.. The problem I ran into was getting the chart >to kick out the exact same size and scale for every one of the charts. I >was not able to identify a way to override the "automated" scaling >function in chart, thus the maximum and minimum shown on the Y axis was >different between charts and had to be changed manually. > >Do newer versions of SPSS make this easier? > >On Wed, 5 Sep 2007 09:44:44 +0200, Monika Heinzel-Gutenbrunner ><[hidden email]> wrote: > > > >>Dear all, >> >> >> >>I wonder if GPL offers any possibility of changing the size of lettering >>and the gauge of lines (e.g. axes) by means of syntax. We have a number >>of graphs that have to be plotted time and again with other data. If the >>formatting of axes, lines, lettering and graphs has to be entered >>manually by means of the GRAPH EDITOR, it is very time-consuming. Using >>templates is of no real help, either. >> >> >> >>I would very much appreciate your help. Thank you. >> >> >> >>Best regards, >> >> >> >>Monika Heinzel-Gutenbrunner >> >> > > > |
| Free forum by Nabble | Edit this page |
