cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
terapin
Level VI

JSL Script to Initialize Data as Date Sequence

I'm trying to write some JSL code that will:

1) prompt user for starting and ending dates for range of data to initialized

2) create new table and have this table add the number of rows equal to end date - start date, initialize new column with dates that increment by 1 day per row.

Does anyone have any suggestions on how to accomplish this? I've included my test code so far. Thanks.

Ron


Dialog(
VList(
LineUp(2,
"Set Initial Date as mm/dd/yyyy", sdate=EditNumber(),
"Set Ending Date as mm/dd/yyyy", edate=EditNumber()),
HList(Button("OK"), Button("Cancel"))));


New Table( "Untitled 4",
Add Rows(edate-sdate ),
New Column( "Sequential Dates",
Numeric,
Continuous,
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Set Values(sequence(sdate,edate,1,0)
[]
)
)
)
8 REPLIES 8
ms
Super User (Alumni) ms
Super User (Alumni)

Re: JSL Script to Initialize Data as Date Sequence

I just made a few changes to your test code to make it work the way I think you want it.

mpb
mpb
Level VII

Re: JSL Script to Initialize Data as Date Sequence

I had trouble with the format m-d-y so I changed it to m/d/y. Also I added one extra row in order to include the end date, and I used the "In Days(1)" function in place of the explicit calculations of seconds in a day.
terapin
Level VI

Re: JSL Script to Initialize Data as Date Sequence

Thanks mpb and MS. Both suggestions were very helpful. I'm learning a lot about lists from this exercise. I had to modify MS' code to add an extra row for the edate (edate - sdate + 86400).

I've been playing with how to format the sdate and edate EditNumber fields to display the entered data as mm/dd/yyyy instead of a number. I can't seem to get that to work. Any suggestions on how to accomplish this? Thanks.
mpb
mpb
Level VII

Re: JSL Script to Initialize Data as Date Sequence

Try the following modified script. I don't see an easy way to do validation of the entered dates though I think it can be done with some effort.

terapin
Level VI

Re: JSL Script to Initialize Data as Date Sequence

I tried your new code but the values displayed in the dialog box are still numeric and not displayed as date. That is, entering 01/01/2010 becomes 3345148800. Not sure why it worked for you and not me.
mpb
mpb
Level VII

Re: JSL Script to Initialize Data as Date Sequence

Are you sure you ran the most recent code? It has EditText boxes instead of Edit Number boxes. There's no way the text entered could be converted to a JMP date number in the dialog. Try running it after closing and then opening JMP. And yes, I just started up JMP and copy/pasted the new code into a script window. It ran successfully. Let me know how it goes.
terapin
Level VI

Re: JSL Script to Initialize Data as Date Sequence

Sorry mpb,

I was total dork and didn't notice that shifted from EditNumber to EditText. The code worked like a charm, as you thought it would. Thanks a ton for your help with this.

Ron
ms
Super User (Alumni) ms
Super User (Alumni)

Re: JSL Script to Initialize Data as Date Sequence

I do not have the m/d/y option for column format and if I choose by JSL I get an error. That's why I changed to m-d-y. However the dialog in the script accepted dates given as m/d/y. Maybe an OS or OS localization "feature" (here JMP 8.0.2 running on Swedish Mac OS X).