Hi there,
I would like to plot a series of revenue data on quarter and year using proc sgplot. The data I have is like the following:
| Year | Quarter | Revenue |
| 2020 | Q1 | 4,215 |
| Q2 | 4,868 | |
| Q3 | 7,520 | |
| Q4 | 7,045 | |
| 2021 | Q1 | 6,653 |
| Q2 | 9,113 | |
| Q3 | 4,676 | |
| Q4 | 2,933 | |
| 2022 | Q1 | 3,701 |
| Q2 | 3,692 | |
| Q3 | 3,721 | |
| Q4 | 5,478 |
In Excel, I can make a series like the following:
However, I can't figure out how to make X axis having quarter and year using proc sgplot like it did in Excel. Any tricks here please?
Thank you.
Here is one way:
proc sgpanel data=sashelp.prdsale;
panelby year / layout=columnlattice noheaderborder colheaderpos=bottom novarname;
colaxis display=(nolabel) values=(1 2 3 4) valuesdisplay=("Q1" "Q2" "Q3" "Q4");
vline quarter / response=actual markers;
run;
In your case, you have Q1-Q4 in your data instead of 1-4, so you can drop the VALUES and VALUESDISPLAY option.
Hope this helps!
Dan
Thank you all for answering my question! I think @Ksharp 's answer is most relevant to my situation, although I still don't know how to put year under months, but yeah, it's almost there.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.