cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar

How to calculate Day/Month

I have a data set with a time column covering 10 years of data. How can I calculate month/day (without year) from this column? I want to place this new variable on x axis and overlay my plot by year to look at the trend of my variable (ozone concentration) year-over-year. One idea is to use Day of Year, but I want to show the months on the x axis too which is not possible with Day of Year. Any suggestions?

4 REPLIES 4
txnelson
Super User

Re: How to calculate Day/Month

I would do it by creating 2 new columns;  Assuming your current date column is called :Date, I did the following

  1. Create a new column called Year, with the following formula
    Year(:Date);
  2. Create a new column called Month_Day.  All of the values will have the same year, to standardize the Month_Day.  
    DateMDY(month(:Date), Day(:Date), 2020);
    and apply this custom format to the new column
    monthList = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
    };
    monthList[Month( :value )] || "/" || Char( Day( :value ) );
    overlay.PNG
  3. Attached is the data table that created this graph, along with the script
Jim
shasheminassab
Level IV

Re: How to calculate Day/Month

Thanks @txnelson for the advice. The only issue with this method is that I cannot easily control the min, max, and interval of the x axis since it not really a date format. 

txnelson
Super User

Re: How to calculate Day/Month

The column "Adjusted month_day" is a JMP Date column.  It is only displayed using a custom format.  Yes, if you want to go to the Axis setting for the X axis, you would have to enter the values in in the raw date value( the number of seconds since January 1st, 1904), but interactively, you can move, compress, expand the axis normally, and if you are setting the values in JSL, you can always use the Informat() function to set the min, max values in a user friendly structure

gb = Graph Builder(
	Variables( X( :Adjusted month_day ), Y( :Y ), Overlay( :Year ) ),
	Elements( Points( X, Y, Legend( 15 ) ), Smoother( X, Y, Legend( 16 ) ) )
);
report(gb)[AxisBox(1)] << min( informat("05/01/2020","m/d/y")) << inc( in weeks(1));

english.PNG

Jim

Re: How to calculate Day/Month

Wonderful!! Thanks.