[CLOSED] Best method to generate a list of months in a date range
I'm going to need to graph a number (ie, count of something) for every month. But it's possible the data has no records during a month that will be during the specified period.
So for example....
2011/01 5 2011/02 0 2011/03 0 2011/04 10
etc.
I can do the counts easily enough, but need the months list to start from. I'd prefer to generate the list of months on the fly, since I'll know the start and end month anyhow. Then I can join the data to that and calculate on from there.
So - has anyone done something like this before? I'd need to generate the list of months as well as the master file, but I'd love to clear both afterwards as if they were a hold file.
I could do a loop with -write in dialogue manager and use a dos command to delete the files afterwards...but surely there must be a better way??This message has been edited. Last edited by: Keith MacDonald,
WebFOCUS & DataMigrator 7.7.03M Windows 2003, Windows 2008 x64
August 17, 2011, 03:30 PM
ABT
Would DATEDIF for your start/end date and an M flag work?
Sure, Datedif could work to create the list of dates. I could do that with dialogue manager and -WRITE. But that doesn't generate a master file (automatically) and also leaves a file behind after execution. I was trying to think of a way to...create a hold file? Rather than a SAVE file.
WebFOCUS & DataMigrator 7.7.03M Windows 2003, Windows 2008 x64
August 17, 2011, 04:47 PM
Doug
Consider using ROWS or COLUMNS to complete the list of desired months...
August 17, 2011, 04:47 PM
j.gross
quote:
I was trying to think of a way to...create a hold file?
To create a month-dimension file: EX MAKESEQ, with FIRST=0, LAST=(the number of months in the period of interest, minus 1).
DEFINE Month (in FSEQ) as the initial date plus COUNTER months.
Then merge with the original HOLD file (using MATCH FILE) to supply rows with zero-valued statistics for the idle months.This message has been edited. Last edited by: j.gross,
August 17, 2011, 04:53 PM
jfr99
Hi Keith,
Take a look at this and see if this might work. This creates a temp file along with a master file.