Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Sum totals by month from date field

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 11, 2010 10:23 AM
(9607 views)

Is there a simple way to create sum totals by month? I have a date field such as 01Apr2008 and I would like to tabulate by month.

I can display the date as only a month-year, such as 4/2008, but I can't use the tabulate function as it does it by day based on the underlying data.

I can display the date as only a month-year, such as 4/2008, but I can't use the tabulate function as it does it by day based on the underlying data.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I am not sure exactly what you want but you could make a month-only variable by adding a new column with the simple formula

Month(:Date) //assuming Date is the name of your date column

This will yield a numeric column with numbers 1-12. These can be recoded (use e.g. Recode in the Cols menu) to Jan-Dec if you prefer that. Use this column with Summary or Tabulate to get monthly statistics.

However, if you want summarize by both month and year then you could also make a Year(:Date) column and then group after both columns.

Alternatively make a a combined column with the formula (choose format m-y to avoid showing the date)

Date DMY( 1, Month( :Date ), Year( :Date ) )

Or by concatenating the month and year columns I described above using the column formula

Char( :Month ) || "-" || Char( :Year )

The last example gives a nominal month-year though, which may or may not be desired.

Month(:Date) //assuming Date is the name of your date column

This will yield a numeric column with numbers 1-12. These can be recoded (use e.g. Recode in the Cols menu) to Jan-Dec if you prefer that. Use this column with Summary or Tabulate to get monthly statistics.

However, if you want summarize by both month and year then you could also make a Year(:Date) column and then group after both columns.

Alternatively make a a combined column with the formula (choose format m-y to avoid showing the date)

Date DMY( 1, Month( :Date ), Year( :Date ) )

Or by concatenating the month and year columns I described above using the column formula

Char( :Month ) || "-" || Char( :Year )

The last example gives a nominal month-year though, which may or may not be desired.

9 REPLIES 9

Highlighted
I am not sure exactly what you want but you could make a month-only variable by adding a new column with the simple formula

Month(:Date) //assuming Date is the name of your date column

This will yield a numeric column with numbers 1-12. These can be recoded (use e.g. Recode in the Cols menu) to Jan-Dec if you prefer that. Use this column with Summary or Tabulate to get monthly statistics.

However, if you want summarize by both month and year then you could also make a Year(:Date) column and then group after both columns.

Alternatively make a a combined column with the formula (choose format m-y to avoid showing the date)

Date DMY( 1, Month( :Date ), Year( :Date ) )

Or by concatenating the month and year columns I described above using the column formula

Char( :Month ) || "-" || Char( :Year )

The last example gives a nominal month-year though, which may or may not be desired.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Month(:Date) //assuming Date is the name of your date column

This will yield a numeric column with numbers 1-12. These can be recoded (use e.g. Recode in the Cols menu) to Jan-Dec if you prefer that. Use this column with Summary or Tabulate to get monthly statistics.

However, if you want summarize by both month and year then you could also make a Year(:Date) column and then group after both columns.

Alternatively make a a combined column with the formula (choose format m-y to avoid showing the date)

Date DMY( 1, Month( :Date ), Year( :Date ) )

Or by concatenating the month and year columns I described above using the column formula

Char( :Month ) || "-" || Char( :Year )

The last example gives a nominal month-year though, which may or may not be desired.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

that did the trick, thanks!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

I think I just came up with a more elegant solution in a similar recent thread. I thought the problem seemed familiar, that I've been digging in to this not long ago. How ephemeral memory is! Glad you've found a solution.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

Can you post or link to the more elegant solution. I'm trying to do something similiar with "Week-Year"

Thanks.

Thanks.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

There is a Week of Year function which assumes weeks begin on Sunday so you may get a week fragment at the beginning and another one (week 53) at the end of a year.

There is a Day of Year function which can be used to calculate a different Week of Year value which starts a full 7 day week on the first day of the year. There will be a 1 or 2 day week 53 fragment at the end of the year. That formula is:

Floor( (Day Of Year( :Date ) - 1) / 7 ) + 1

One way or the other you will have a new column of weeks of the year.

Message was edited by: mpb

There is a Day of Year function which can be used to calculate a different Week of Year value which starts a full 7 day week on the first day of the year. There will be a 1 or 2 day week 53 fragment at the end of the year. That formula is:

Floor( (Day Of Year( :Date ) - 1) / 7 ) + 1

One way or the other you will have a new column of weeks of the year.

Message was edited by: mpb

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

Right - I'm actually trying to create a new variable that includes YEAR & WEEK of YEAR. The goal is to look at trends by WEEK across YEARS.

So we'd lke to get something like YYYWW or 200940. The variable needs to be stored as a numeric variable ideally.

So we'd lke to get something like YYYWW or 200940. The variable needs to be stored as a numeric variable ideally.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

Well you can use the Year function to get a column containing the year. Then you can model by Year and Week. Or you can make a value like your 200940 by creating a new column whose values are Year*100 + Week if that's what you want. There is no JMP format which displays a date as YYYYWW.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

i am doing something similar to that described by MS (actually working out average yields by month) and haven't yet found a nicer way.

unfortunately, if i want to plot a bar chart with months as the x-axis and there are months with no data, then that month doesn't get plotted at all, so to make sure there's an empty month in my chart i have to create dummy empty rows, and i'm sure there should be a better way than that!

unfortunately, if i want to plot a bar chart with months as the x-axis and there are months with no data, then that month doesn't get plotted at all, so to make sure there's an empty month in my chart i have to create dummy empty rows, and i'm sure there should be a better way than that!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Sum totals by month from date field

If you can live with month numbers (1-12) and you don't mind creating a summary table of average yields by month, then with a little effort you can do what you want using Overlay Plot.

Plot Avg Yield versus Month.

Make into a Needle plot via Y Options

Right Click in the plot and choose Line Width Scale > Other > 30 (say)

Turn off Show Points

If you save the script to table or script window it will reproduce the same effect.

Plot Avg Yield versus Month.

Make into a Needle plot via Y Options

Right Click in the plot and choose Line Width Scale > Other > 30 (say)

Turn off Show Points

If you save the script to table or script window it will reproduce the same effect.