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...
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')))
Please see this post on same topic.
@Jay54, 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;
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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.