10-21-2015 02:18 AM - edited 10-21-2015 02:22 AM
Should I be able to use a picture format in SGPLOT?
I created a picture format using a date directive for the week number ('%W').
When I generate a scatter plot using PROC SGPLOT, the x-axis tick labels are rendered as %W instead of 01, 02, 03, etc.
However, if I use my picture format with PROC GPLOT, the x-axis tick labels are displayed correctly.
(I'm familiar with the weekw3. format, but I don't want the extra 'W' in front of every value in my x-axis -- W01, W02, W03, etc. And I need to use some specific features of SGPLOT rather than reverting to GPLOT.)
I found a few other posts on this topic, but the suggested workaround is to convert the x-axis variable to a formatted character value. I don't think my irregularly-spaced time series data will be plotted correctly if I convert all the dates to formatted characted values.
Does anyone have any insights about using picture formats in PROC SGPLOT?
Thanks in advance...
10-21-2015 04:08 AM - edited 10-21-2015 04:08 AM
I don't know if it's a proper solution, but you always could extrat your TPL code from the SGPLOT (option TMPLOUT) and edit the layout XAXISOPTS with something like that if you know the number of weeks.
Layout overlay / XAXISOPTS= (LINEAROPTS=(tickvaluelist=(1 2 3) tickdisplaylist=('01' '02' '03')))
10-21-2015 08:52 AM
Please see this post on same topic.
10-23-2015 04:44 PM
@Sanjay_SAS, Function-formats (fcmp) don't work with sg procs either.
proc fcmp outlib=work.fcmp.fmt; function weekfmt(date) $2; return(put(week(date),z2.0)); endsub; run; options cmplib=(work.fcmp); proc format; value weekfmt other=[weekfmt()]; run; /* Doesn't work */ proc sgplot data=sashelp.Citiday; format date weekfmt.; series x=date y=SNYDJCM; run; /* But this works */ proc print data=sashelp.citiday(obs=20); format date weekfmt.; run;
10-23-2015 05:02 PM
You could get away with something like this, I guess
data myGraph; set sashelp.Citiday; /* Weeks starting on a Sunday */ myDate = intck("DAY", "27DEC1987"d, date) / 7; format mydate z3.0; run; proc sgplot data=myGraph; series x=mydate y=SNYDJCM; xaxis integer label="Week Number"; run;