I was looking to specify start values for a date variable in a graph, as well as the number of dates in between ticks (the data is aggregated weekly, so I want 7 days in between ticks and starting at a specific date).
Below is an quick example to show what I expected the format to be, but it isn't clear how to pass date/time parameters to the start and delta functions in GGRAPH (the manual gives no examples as far as I can tell either). I'm using V15 and the below example does not work, but I would certainly like to know how to do it in general (even if it is not possible in V15). *****************************************************. data list free / weekN y. begin data 0 4 1 5 2 6 3 7 end data. dataset name weekdata. compute #days = weekN*7. compute #start = DATE.MDY(09,21,2012). compute weekD = DATESUM(#start,#days,"days"). formats weekD (ADATE10). exe. *Base chart that does work. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=weekD y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: weekD=col(source(s), name("weekD"), unit.time(), format("MM/dd/yy")) DATA: y=col(source(s), name("y")) GUIDE: axis(dim(1), label("Week")) GUIDE: axis(dim(2), label("y")) ELEMENT: line(position(weekD*y)) END GPL. *This is how I would guess it works, but it does not. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=weekD y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: weekD=col(source(s), name("weekD"), unit.time(), format("MM/dd/yy")) DATA: y=col(source(s), name("y")) GUIDE: axis(dim(1), label("Week"), start("09/21/2012"), delta(7)) GUIDE: axis(dim(2), label("y")) ELEMENT: line(position(weekD*y)) END GPL. *****************************************************. |
Oh, this is very interesting. I am on 21 and here's what I see.
2nd chart has no labelling at all. I open it in the chart editor and the data format is set to automatic. I check the scale values and the delta is set to 7. If I make the delta Auto and apply it, the delta then shows 604800 which is probably time in seconds but I also get nice 7 day intervals. Now if I override the automatic Date format and set it mm/dd/yyyy, the delta goes back to 7 but also works just fine. I smell an initialization bug here. A template fixes that issue up. Unfortunately, I can't get it to set the start date to 9/21/2012 and it insists on making it 9/20. I could override this by making it custom but presumably you want something that works with different data ranges. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W Sent: Monday, March 25, 2013 8:04 AM To: [hidden email] Subject: Start and delta for dates in graphs (GPL)? I was looking to specify start values for a date variable in a graph, as well as the number of dates in between ticks (the data is aggregated weekly, so I want 7 days in between ticks and starting at a specific date). Below is an quick example to show what I expected the format to be, but it isn't clear how to pass date/time parameters to the start and delta functions in GGRAPH ( the manual <http://www.unt.edu/rss/class/Jon/SPSS_SC/Manuals/v19/GPL%20Reference%20Guid e%20for%20IBM%20SPSS%20Statistics.pdf> gives no examples as far as I can tell either). I'm using V15 and the below example does not work, but I would certainly like to know how to do it in general (even if it is not possible in V15). *****************************************************. data list free / weekN y. begin data 0 4 1 5 2 6 3 7 end data. dataset name weekdata. compute #days = weekN*7. compute #start = DATE.MDY(09,21,2012). compute weekD = DATESUM(#start,#days,"days"). formats weekD (ADATE10). exe. *Base chart that does work. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=weekD y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: weekD=col(source(s), name("weekD"), unit.time(), format("MM/dd/yy")) DATA: y=col(source(s), name("y")) GUIDE: axis(dim(1), label("Week")) GUIDE: axis(dim(2), label("y")) ELEMENT: line(position(weekD*y)) END GPL. *This is how I would guess it works, but it does not. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=weekD y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: weekD=col(source(s), name("weekD"), unit.time(), format("MM/dd/yy")) DATA: y=col(source(s), name("y")) GUIDE: axis(dim(1), label("Week"), start("09/21/2012"), delta(7)) GUIDE: axis(dim(2), label("y")) ELEMENT: line(position(weekD*y)) END GPL. *****************************************************. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Start-and-delta-for-dates-in-g raphs-GPL-tp5719066.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 ===================== 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 |
Free forum by Nabble | Edit this page |