ID'ing The Year A Date Falls In

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

ID'ing The Year A Date Falls In

israpound
I am positive there is an easier way to do this.  For example, I have a
working\base file with 100 records and each record has a date field (one
date per record).  And these dates can occur in any of the last 10 years
(2002 to 2012).  The issue is the years are not based on calendar years
rather fiscal years, therefore the year in the aforementioned date field
will not necesary correspond with the calendar year, e.g., state fiscal
year (SFY) 2007 is July 1, 2006 through June 30, 2007.  Historically, I've
created a file of 10 begin or end dates associated with each SFY (merge
onto the working\base file) and used a "do repeat" or "vector\loop" to ID
what SFY the date falls in. The end result is a variable\field "SFY"
associated with each record which indicates, 2007, 2004, 2011, etc.  I am
thinking this can be done without creating a separate file of begin or end
dates but I am at a loss as to how, perhaps a "macro"?  Any
help\suggestions will be appreciated!

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

Rich Ulrich
Please clarify, if necessary ...

Do you have different dates for different states?
Do you have different dates for different years?

If it is always July 1, I presume that you could add 184 days
(times seconds per day) to the observed date, and extract
the year using a date function.

Or, if there is one vector of alternatives, by years or by
states, you could place the set of constants in a vector, and
use the state/year  index to pick up the right add-on value.

--
Rich Ulrich

> Date: Fri, 13 Jul 2012 11:51:47 -0400

> From: [hidden email]
> Subject: ID'ing The Year A Date Falls In
> To: [hidden email]
>
> I am positive there is an easier way to do this. For example, I have a
> working\base file with 100 records and each record has a date field (one
> date per record). And these dates can occur in any of the last 10 years
> (2002 to 2012). The issue is the years are not based on calendar years
> rather fiscal years, therefore the year in the aforementioned date field
> will not necesary correspond with the calendar year, e.g., state fiscal
> year (SFY) 2007 is July 1, 2006 through June 30, 2007. Historically, I've
> created a file of 10 begin or end dates associated with each SFY (merge
> onto the working\base file) and used a "do repeat" or "vector\loop" to ID
> what SFY the date falls in. The end result is a variable\field "SFY"
> associated with each record which indicates, 2007, 2004, 2011, etc. I am
> thinking this can be done without creating a separate file of begin or end
> dates but I am at a loss as to how, perhaps a "macro"? Any
> help\suggestions will be appreciated!
>
...<snip List messages>
Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

israpound
In reply to this post by israpound
Exit Date PeriodEnd1 PeriodEnd2.....PeriodEnd10 SFY

Record 1   02/03/2005 06/30/2002 06/30/2003.....06/30/2012   2005
Record 2   11/12/2007 06/30/2002 06/30/2003.....06/30/2012   2008
Record 3   12/02/2004 06/30/2002 06/30/2003.....06/30/2012   2005
.
.
.
.
Record 100 05/06/2010 06/30/2002 06/30/2003.....06/30/2012   2010

Not sure if this clarifies things or not, but I create the "PeriodEnd" file
and hang on the base\working file and simply write code which determines
which two "periodend" dates the exit date falls between and this
determination populates the SFY variable\field. I am just thinking
creating the "PeriodEnd" file isn't necessary, i.e., must be a more
streamlined way to do it.  I realize that I could ID the month in the exit
date and depending what it is use the year associated with the exit date
as the SFY or add a 1 to the exit date's year and use it as the SFY but
does another option exist beyond doing this or adding a "PeriodEnd" file?

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

Melissa Ives
In reply to this post by Rich Ulrich

Could you do something like (FY2012=7/1/11 to 6/30/12):

 

If (xdate.month(mydate) gt 6) FYy= xdate.year(mydate)-1.

If (xdate.month(mydate) le 6) xdate.year(mydate).

 

Melissa

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Rich Ulrich
Sent: Friday, July 13, 2012 11:56 AM
To: [hidden email]
Subject: Re: [SPSSX-L] ID'ing The Year A Date Falls In

 

Please clarify, if necessary ...

Do you have different dates for different states?
Do you have different dates for different years?

If it is always July 1, I presume that you could add 184 days
(times seconds per day) to the observed date, and extract
the year using a date function.

Or, if there is one vector of alternatives, by years or by
states, you could place the set of constants in a vector, and
use the state/year  index to pick up the right add-on value.

--
Rich Ulrich

> Date: Fri, 13 Jul 2012 11:51:47 -0400
> From: [hidden email]
> Subject: ID'ing The Year A Date Falls In
> To: [hidden email]
>
> I am positive there is an easier way to do this. For example, I have a
> working\base file with 100 records and each record has a date field (one
> date per record). And these dates can occur in any of the last 10 years
> (2002 to 2012). The issue is the years are not based on calendar years
> rather fiscal years, therefore the year in the aforementioned date field
> will not necesary correspond with the calendar year, e.g., state fiscal
> year (SFY) 2007 is July 1, 2006 through June 30, 2007. Historically, I've
> created a file of 10 begin or end dates associated with each SFY (merge
> onto the working\base file) and used a "do repeat" or "vector\loop" to ID
> what SFY the date falls in. The end result is a variable\field "SFY"
> associated with each record which indicates, 2007, 2004, 2011, etc. I am
> thinking this can be done without creating a separate file of begin or end
> dates but I am at a loss as to how, perhaps a "macro"? Any
> help\suggestions will be appreciated!
>
...<snip List messages>



PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

Rich Ulrich
In reply to this post by israpound
Okay.  You do seem to have the simplest case, where the year
for SFY is always the next year, for dates after June 30.

Here is my previous suggestion in more detail, ignoring the
possibilities of having different Fiscal years for different cases.

There are 184 days after June 30.  If you add 184 days to
June 30, you get Dec 31 of the same year.  If you add it to
July 1, you get Jan 1 of the next year.  That is the year that
you want.

Instead of bothering with pulling out both the date and
month and doing IF statements, all you need to do is to
add 184 days to your present date, and pull out the year
for that.  Since dates are stored in "seconds", you can add
184 days by adding the quantity 184*86400  to the exit date.

 - I would probably use the whole term, 184*86400, instead
of multiplying it out, so that the documentation Comment
can be simple and the code be easy to verify by inspection.

--
Rich Ulrich

> Date: Fri, 13 Jul 2012 14:32:45 -0400

> From: [hidden email]
> Subject: Re: ID'ing The Year A Date Falls In
> To: [hidden email]
>
> Exit Date PeriodEnd1 PeriodEnd2.....PeriodEnd10 SFY
>
> Record 1 02/03/2005 06/30/2002 06/30/2003.....06/30/2012 2005
> Record 2 11/12/2007 06/30/2002 06/30/2003.....06/30/2012 2008
> Record 3 12/02/2004 06/30/2002 06/30/2003.....06/30/2012 2005
> .
> .
> .
> .
> Record 100 05/06/2010 06/30/2002 06/30/2003.....06/30/2012 2010
>
> Not sure if this clarifies things or not, but I create the "PeriodEnd" file
> and hang on the base\working file and simply write code which determines
> which two "periodend" dates the exit date falls between and this
> determination populates the SFY variable\field. I am just thinking
> creating the "PeriodEnd" file isn't necessary, i.e., must be a more
> streamlined way to do it. I realize that I could ID the month in the exit
> date and depending what it is use the year associated with the exit date
> as the SFY or add a 1 to the exit date's year and use it as the SFY but
> does another option exist beyond doing this or adding a "PeriodEnd" file?
>
<... snip, List comments>
Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

Jon K Peck
For readability, I would suggest using the datesum function, e.g.,
COMPUTE adjDate=datesum(date, 184, "days") or
COMPUTE adjDate = date + 184 * time.days(1).

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Rich Ulrich <[hidden email]>
To:        [hidden email]
Date:        07/13/2012 05:39 PM
Subject:        Re: [SPSSX-L] ID'ing The Year A Date Falls In
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Okay.  You do seem to have the simplest case, where the year
for SFY is always the next year, for dates after June 30.

Here is my previous suggestion in more detail, ignoring the
possibilities of having different Fiscal years for different cases.

There are 184 days after June 30.  If you add 184 days to
June 30, you get Dec 31 of the same year.  If you add it to
July 1, you get Jan 1 of the next year.  That is the year that
you want.

Instead of bothering with pulling out both the date and
month and doing IF statements, all you need to do is to
add 184 days to your present date, and pull out the year
for that.  Since dates are stored in "seconds", you can add
184 days by adding the quantity 184*86400  to the exit date.

- I would probably use the whole term, 184*86400, instead
of multiplying it out, so that the documentation Comment
can be simple and the code be easy to verify by inspection.

--
Rich Ulrich

> Date: Fri, 13 Jul 2012 14:32:45 -0400
> From: [hidden email]
> Subject: Re: ID'ing The Year A Date Falls In
> To: [hidden email]
>
> Exit Date PeriodEnd1 PeriodEnd2.....PeriodEnd10 SFY
>
> Record 1 02/03/2005 06/30/2002 06/30/2003.....06/30/2012 2005
> Record 2 11/12/2007 06/30/2002 06/30/2003.....06/30/2012 2008
> Record 3 12/02/2004 06/30/2002 06/30/2003.....06/30/2012 2005
> .
> .
> .
> .
> Record 100 05/06/2010 06/30/2002 06/30/2003.....06/30/2012 2010
>
> Not sure if this clarifies things or not, but I create the "PeriodEnd" file
> and hang on the base\working file and simply write code which determines
> which two "periodend" dates the exit date falls between and this
> determination populates the SFY variable\field. I am just thinking
> creating the "PeriodEnd" file isn't necessary, i.e., must be a more
> streamlined way to do it. I realize that I could ID the month in the exit
> date and depending what it is use the year associated with the exit date
> as the SFY or add a 1 to the exit date's year and use it as the SFY but
> does another option exist beyond doing this or adding a "PeriodEnd" file?
>
<... snip, List comments>

Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

David Marso
Administrator

Ah hell, everyone knows there are 86400 seconds in an earth day ;-)))
Jon K Peck wrote
For readability, I would suggest using the datesum function, e.g.,
COMPUTE adjDate=datesum(date, 184, "days") or
COMPUTE adjDate = date + 184 * time.days(1).

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:   Rich Ulrich <[hidden email]>
To:     [hidden email]
Date:   07/13/2012 05:39 PM
Subject:        Re: [SPSSX-L] ID'ing The Year A Date Falls In
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Okay.  You do seem to have the simplest case, where the year
for SFY is always the next year, for dates after June 30.

Here is my previous suggestion in more detail, ignoring the
possibilities of having different Fiscal years for different cases.

There are 184 days after June 30.  If you add 184 days to
June 30, you get Dec 31 of the same year.  If you add it to
July 1, you get Jan 1 of the next year.  That is the year that
you want.

Instead of bothering with pulling out both the date and
month and doing IF statements, all you need to do is to
add 184 days to your present date, and pull out the year
for that.  Since dates are stored in "seconds", you can add
184 days by adding the quantity 184*86400  to the exit date.

 - I would probably use the whole term, 184*86400, instead
of multiplying it out, so that the documentation Comment
can be simple and the code be easy to verify by inspection.

--
Rich Ulrich

> Date: Fri, 13 Jul 2012 14:32:45 -0400
> From: [hidden email]
> Subject: Re: ID'ing The Year A Date Falls In
> To: [hidden email]
>
> Exit Date PeriodEnd1 PeriodEnd2.....PeriodEnd10 SFY
>
> Record 1 02/03/2005 06/30/2002 06/30/2003.....06/30/2012 2005
> Record 2 11/12/2007 06/30/2002 06/30/2003.....06/30/2012 2008
> Record 3 12/02/2004 06/30/2002 06/30/2003.....06/30/2012 2005
> .
> .
> .
> .
> Record 100 05/06/2010 06/30/2002 06/30/2003.....06/30/2012 2010
>
> Not sure if this clarifies things or not, but I create the "PeriodEnd"
file
> and hang on the base\working file and simply write code which determines
> which two "periodend" dates the exit date falls between and this
> determination populates the SFY variable\field. I am just thinking
> creating the "PeriodEnd" file isn't necessary, i.e., must be a more
> streamlined way to do it. I realize that I could ID the month in the
exit
> date and depending what it is use the year associated with the exit date
> as the SFY or add a 1 to the exit date's year and use it as the SFY but
> does another option exist beyond doing this or adding a "PeriodEnd"
file?
>
<... snip, List comments>
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?"
Reply | Threaded
Open this post in threaded view
|

Re: ID'ing The Year A Date Falls In

Albert-Jan Roskam
Only recently, we had a day of 86401 seconds (leap second), and sometimes it's 86399 seconds.
And yesterday appeared to last a multiple of 86400 seconds --TGIF! ;-)
 
Regards,
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

From: David Marso <[hidden email]>
To: [hidden email]
Sent: Saturday, July 14, 2012 4:31 AM
Subject: Re: [SPSSX-L] ID'ing The Year A Date Falls In

Ah hell, everyone knows there are 86400 seconds in an earth day ;-)))

Jon K Peck wrote

>
> For readability, I would suggest using the datesum function, e.g.,
> COMPUTE adjDate=datesum(date, 184, "days") or
> COMPUTE adjDate = date + 184 * time.days(1).
>
> Jon Peck (no "h") aka Kim
> Senior Software Engineer, IBM
> peck@.ibm
> new phone: 720-342-5621
>
>
>
>
> From:  Rich Ulrich &lt;rich-ulrich@&gt;
> To:    SPSSX-L@.uga
> Date:  07/13/2012 05:39 PM
> Subject:        Re: [SPSSX-L] ID'ing The Year A Date Falls In
> Sent by:        "SPSSX(r) Discussion" &lt;SPSSX-L@.uga&gt;
>
>
>
> Okay.  You do seem to have the simplest case, where the year
> for SFY is always the next year, for dates after June 30.
>
> Here is my previous suggestion in more detail, ignoring the
> possibilities of having different Fiscal years for different cases.
>
> There are 184 days after June 30.  If you add 184 days to
> June 30, you get Dec 31 of the same year.  If you add it to
> July 1, you get Jan 1 of the next year.  That is the year that
> you want.
>
> Instead of bothering with pulling out both the date and
> month and doing IF statements, all you need to do is to
> add 184 days to your present date, and pull out the year
> for that.  Since dates are stored in "seconds", you can add
> 184 days by adding the quantity 184*86400  to the exit date.
>
>  - I would probably use the whole term, 184*86400, instead
> of multiplying it out, so that the documentation Comment
> can be simple and the code be easy to verify by inspection.
>
> --
> Rich Ulrich
>
>> Date: Fri, 13 Jul 2012 14:32:45 -0400
>> From: jazzgrve@
>> Subject: Re: ID'ing The Year A Date Falls In
>> To: SPSSX-L@.UGA
>>
>> Exit Date PeriodEnd1 PeriodEnd2.....PeriodEnd10 SFY
>>
>> Record 1 02/03/2005 06/30/2002 06/30/2003.....06/30/2012 2005
>> Record 2 11/12/2007 06/30/2002 06/30/2003.....06/30/2012 2008
>> Record 3 12/02/2004 06/30/2002 06/30/2003.....06/30/2012 2005
>> .
>> .
>> .
>> .
>> Record 100 05/06/2010 06/30/2002 06/30/2003.....06/30/2012 2010
>>
>> Not sure if this clarifies things or not, but I create the "PeriodEnd"
> file
>> and hang on the base\working file and simply write code which determines
>> which two "periodend" dates the exit date falls between and this
>> determination populates the SFY variable\field. I am just thinking
>> creating the "PeriodEnd" file isn't necessary, i.e., must be a more
>> streamlined way to do it. I realize that I could ID the month in the
> exit
>> date and depending what it is use the year associated with the exit date
>> as the SFY or add a 1 to the exit date's year and use it as the SFY but
>> does another option exist beyond doing this or adding a "PeriodEnd"
> file?
>>
> <... snip, List comments>
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/ID-ing-The-Year-A-Date-Falls-In-tp5714202p5714224.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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


Reply | Threaded
Open this post in threaded view
|

Automatic reply: ID'ing The Year A Date Falls In

Matthew Fuller-Tyszkiewicz

Hi,

I'm away on leave until Tuesday 17th July. I will not have access to my email account while away, and willl endeavour to return your emails shortly after my return.


Cheers,
Matt.

 

Reply | Threaded
Open this post in threaded view
|

Automatisk svar: ID'ing The Year A Date Falls In

Henrik Lolle-3
In reply to this post by Albert-Jan Roskam

I am on vacation until August 6

 

Kind regards,

Henrik Lolle