I'm trying to plot multiple time series plot which looks like a spahetti plot. I'm trying to avoid spaghetti plot by using lattice or panel like plots.
Here is the SAS dataset to replicate,I have dataset called "temp" with grouping variable called group. The data is time series with time variable "date" and y variable "air".
data alldata1; set sashelp.air; group = "REF"; keep date air group; run; data alldata2; set sashelp.air; group = "A1"; air=air+30; keep date air group; run; data alldata3; set sashelp.air; group = "A2"; air=air+60; keep date air group; run; data alldata4; set sashelp.air; group = "A3"; air=air-30; keep date air group; run; data alldata5; set sashelp.air; group = "A4"; air=air-60; keep date air group; run; data temp; set alldata1 alldata2 alldata3 alldata4 alldata5; run;
The grouping variable "group" has 5 categories. "REF", A1,A2,A3,A4. I need to creat a chart like the one below where "REF" group highlighted in "red" and each category is highlighted in blue and the rest of the category in light grey.
Below are my questions:
Some answers to help you get started.
1. SGPLOT Series graph, use a BY statement for different graphs or SGPANEL, given sample SGPLOT looks easier.
2. Either PROC GREPLAY and ODS DOCUMENT to control the layout or output to a PDF file with columns=2. It doesn't matter how many categories exist if you use a BY statement it will automatically create them all.
3. Specify the device type under ODS GRAPHICS options statements.
What SAS version do you have? The graphics options vary a bit in the last few. For example, AttributeMaps will allow you to control the colours the easiest and is in the later releases.
HAVE ==== Up to 40 obs from temp total obs=576 Obs DATE AIR GROUP AIR1 1 JAN49 142 A1 112 2 JAN49 172 A2 142 3 JAN49 202 A3 172 4 JAN49 232 A4 202 5 FEB49 148 A1 118 6 FEB49 178 A2 148 7 FEB49 208 A3 178 8 FEB49 238 A4 208 .... 569 NOV60 420 A1 390 570 NOV60 450 A2 420 571 NOV60 480 A3 450 572 NOV60 510 A4 480 573 DEC60 462 A1 432 574 DEC60 492 A2 462 575 DEC60 522 A3 492 576 DEC60 552 A4 522 WANT ( see below) FULL SOLUTION ============= data have; set sashelp.air; do group="A1","A2","A3","A4"; air1=air; air=air+30; output; end; run;quit; options orientation=landscape; ods pdf file="d:/pdf/panel.pdf" notoc; title "Group Panels"; proc sgpanel data=temp; panelby group / columns = 2 rows = 2; series x=date y=air; series x=date y=air1 ; run;quit;
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.