Hi all,
I need some help while creating the graph plots. I am using the following code.
ods graphics on / width=8in height=6in outputfmt=gif imagemap=on border=off;
title1 "SGPLOT Output for &name.";
proc sgplot data=out_ds ;
series x=quarter y=default_flag/ legendlabel="Default Rate" markers lineattrs=(thickness=2);
series x=quarter y=Varname/y2axis legendlabel="Unemployment rate" markers lineattrs=(thickness=2);
xaxis type=discrete display=(noline noticks) grid label="Time Period";
yaxis display=(noline) grid label="Default Rate" ;
y2axis label="Unemployment rate";
run;
The x-axis "quarter" contains the values 2001Q1, 2001Q2, 2001Q3, 2001Q4, 2002Q1..... so on
My input data contains values from 1995Q1 to 2020Q4. So the values of x-axis labels in the graph are coming too close. Since this is character values, I am not able to use values= option.
Is there any way , I can get skip quarters and print only years (with four ticks for each quarter).
Or any other easy way so that the labels are not too close.
Thanks
Your best option here is to use a data step to create a temporary data set that uses an informat on your "quarter" column to turn it into a true datetime value. Then, assign a YYQ. format to that column and let SGPLOT create a time axis for you on the X axis (remove the type=discrete). You might also need to set INTERVAL=QUARTER on that axis statement to get what you want.
Hope this helps!
Dan
Your best option here is to use a data step to create a temporary data set that uses an informat on your "quarter" column to turn it into a true datetime value. Then, assign a YYQ. format to that column and let SGPLOT create a time axis for you on the X axis (remove the type=discrete). You might also need to set INTERVAL=QUARTER on that axis statement to get what you want.
Hope this helps!
Dan
Thanks Dan !! this works perfectly..
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.