Hello all, I am trying to lay a regression line on each of two different (half) series covering different times of period. proc sql;
create table have as
select date
, region
, sum(sale) as sale
from sashelp.pricedata
group by region, date
order by region, date
;
quit;
data have2;
set have (rename=(region=period));
if period=3 then delete;
if period=2 then monthyear=intnx('year',date,5, "sameday");
else monthyear=date;
drop date;
format monthyear monyy5.;
run;
/*CODE 1 PRODUCES SERIES AS EXPECTED*/
proc sgplot data=have2;
series x=monthyear y=sale / group=period markers; label period="PERIOD";
run;
/*CODE 2 PRODUCES REGRESSION LINE AS EXPECTED*/
proc sgplot data=have2;
reg x=monthyear y=sale / group=period ; label period="PERIOD";
run;
/*CODE 3 DOES NOT PRODUCES SERIES OVERLAID WITH REGRESSION LINE*/
*When I add the regression line, all the series line are all over the place;
proc sgplot data=have2;
series x=monthyear y=sale / group=period markers;* markerattrs=(color=lightgreen size=10 symbol=trianglefilled);
reg x=monthyear y=sale / group=period ; label period="PERIOD";
run; I saw a similar example here but it doesn't work for me, presumably because the periods do not overlap. Below is the plot obtained from CODE 1, I just need to have the regression lines through EACH (half) series without distorting the series as CODE 3 does. Please help, thank you!
... View more