After seeing Sanjay Matange's presentation of "Up Your Game with Graph Template Language Layouts" at SGF 2014, I decided to try to make a variation on the BLOCKPLOT with SERIESPLOT overlay from here: SAS(R) 9.3 Graph Template Language: Reference, Third Edition.
I added the Macintosh OS releases as a POC because in my real work life, I sometimes have overlapping temporal events, so I wanted to have multiple views of BLOCKS.
I have tried pasting code into here from EG but it isn't working well, and using Word as an staging clipboard doesn't help. Basically, I made a separate data set for Apple version release dates and merged it onto the STOCKS data set (i had to wiggle some of the dates to get it to merge well).
Then I did:
proc template ;
define statgraph ;
layout overlay ;
layout lattice / rows = 2 columns = 1 ;
[2 block plots]
end layout ;
series plot x = date y = close ;
end layout ;
end ;
run ;
It did NOT work. I got this warning:
WARNING: SERIESPLOT statement has a conflict with the axis type. The plot will not be drawn.
I tried to put close on the secondary YAXIS, and that doesn't give me any errors or warnings, but the series plot doesn't show up. The envelope simply refuses to be pushed any farther!
Is this a hopeless cause?
It is not clear what you are trying to do. Can you attach a sketch or image. You can certainly do this from your program. You can overlay plots in one overlay container, but not across cells of a lattice. Is this what you want?
It is not clear what you are trying to do. You say you want to overlay a SERIES on a BLOCK. That in itself not a problem, as shown in the example you are referencing. It is not clear why you have nested a LATTICE inside the OVELAY. Also, you do not provide information on the data or the block plot settings. It is easier to help if you attach full working program with data.
Sorry for the delay in responding. I thought I would get a notification if anyone responded in this thread.
Here's the full code. I'm sorry it's not formatted but I had to use a plain text editor to get it to paste here without lots of extra line breaks.
data MSevents ;
input Date date9. MRelease $5. ;
label MRelease = "Windows Release" ;
datalines ;
01jun1990 3.0
01sep1995 95
01jul1998 98
01mar2000 2000
01nov2001 XP
;
run ;
data AppleEvents ;
input Date date9. ARelease $5. ;
label ARelease = "Apple Release" ;
datalines ;
01may1991 OS 7
01aug1997 OS 8
01nov1999 OS 9
02apr2001 OS X
;
run ;
proc sql ;
create table Events as
select distinct d.date format = mmddyy10.,
MRelease,
ARelease
from (select date
from MSEvents
union all
select date
from AppleEvents) as d
left join
MSEvents as ms
on d.date eq ms.date
left join
AppleEvents as a
on d.date eq a.date ;
quit ;
data MSevents ;
input Date date9. Release $5. ;
label Release = "Windows Release" ;
datalines ;
01jun1990 3.0
01sep1995 95
01jul1998 98
01mar2000 2000
01nov2001 XP
01nov2002
;
run ;
proc sort data = sashelp.stocks (keep = date stock close)
out = MSstock ;
where stock = "Microsoft" ;
by date ;
run ;
data Stock_Events ;
merge MSstock Events ;
by date ;
run ;
proc template ;
define StatGraph LayerBlock2 ;
BeginGraph ;
Layout Overlay / xaxisopts = (timeopts = (interval = month))
y2axisopts = (linearopts = (viewmin = 0 viewmax = 500)) ;
Layout Lattice / rows = 2 columns = 1 ;
BlockPlot x = date
block = mrelease / DataTransparency = .7
Display = (fill)
ExtendBlockOnMissing= true ;
BlockPlot x = date
block = arelease / DataTransparency = .7
Display = (fill)
ExtendBlockOnMissing= true ;
EndLayout ;
SeriesPlot x = date
y = close /*/yaxis = y2*/ ;
EndLayout ;
EndGraph ;
end ;
run ;
proc sgrender data = Stock_Events template = LayerBlock2 ;
run ;
It is not clear what you are trying to do. Can you attach a sketch or image. You can certainly do this from your program. You can overlay plots in one overlay container, but not across cells of a lattice. Is this what you want?
Sanjay-
Thanks. I wanted to try to overlay a plot across the cells of the lattice. So it'd be like what you have, but only one series plot.
Back to the drawing board, then.
Thanks,
Jed
Also you might check your data types used in your series. The warning makes me suspect that possibly one of your variables is character where the proc is expecting numeric.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.