I'm running SAS 9.3, and I'm trying to create a plot using PROC SGPLOT that (1) shows only dates contained in my dataset as consecutive dates (ie, excluding weekends and holidays), while (2) displaying usable information on the XAXIS (eg, the first day of a month). I can do both of these separately, but I can't figure out a way both of these together. Specifically, the VALUE and TICKVALUEFORMAT options seem to be disabled when I use the DISCRETE option (I don't see any discussion of this in the documentation).
So I have 2 questions:
(1) Is there a way to solve this interaction between the DISCRETE option and VALUES/TICKVALUES?
(2) Is there a better way to do what I'm trying to do?
(The PERFECT thing would to plot X and Y variables, and use a third variable as labels for the x-axis, but I can't find a way to do this.)
Here is some sample code that illustrates this; if excluding weekends/holidays, then the code should plot a straight line (I've attached plots generated below):
*Create Dataset of Weekdays, dropping some holidays;
data weekdays (where=(weekday~=1 and weekday~=7 and date~="01JAN1960"d));
format date date9.;
do i=0 to 100;
date=i;
weekday=weekday(date);
year=year(date);
month=year*100+month(date);
output;
end;
drop i;
run;
*Create line and data label;
data weekdays;
set weekdays;
line=_n_;
format xlab $12.;
by month;
if first.month then xlab=put(date,monyy7.);
run;
The following plots the dates as DISCRETE points: it plots the datapoints correctly, but the VALUES and TICKVALUEFORMAT commands have no impact:
*Plot dates as discrete -- correct points, VALUES and TICKVALUEFORMAT have no effect;
proc sgplot data=weekdays;
series x=date y=line;
scatter x=date y=line;
xaxis type=discrete DISCRETEORDER=DATA values=(3 31 60 91) TICKVALUEFORMAT=monyy7.;
run;
Here is the first plot: correct points, wrong axis
The following code is the same, but removes the DISCRETE option, and therefore it gets plotted as a date axis, which obviously includes weekends, but the VALUE and TICKVALUEFORMAT options work:
*Plot all dates as dates -- incorrect points, but VALUE and TICKVALUEFORMAT work;
proc sgplot data=weekdays;
series x=date y=line;
scatter x=date y=line;
xaxis values=(3 31 60 91) TICKVALUEFORMAT=monyy7.;
run;
Here is the second plot: wrong points, but working axis
Any suggestions would be warmly welcomed! Thank you!