In some cases my x axis is being formatted with year like 2001.5 2002 2002.5. How can I format it as 2001 2002 2003?
proc template;
define statgraph multiLineGraph2;
begingraph;
layout
overlay / xaxisopts =(label = ' ') yaxisopts =(label = ' ' linearopts=(viewmin=0)) walldisplay=(fill);
seriesplot x=FOUR_DIGIT_YEAR y= mergedColumn / group= columnDisplay name='a' index=index display=all;
endlayout;
endgraph;
end;
run;
proc sgrender data=combined2 template=multiLineGraph2;
format mergedColumn 4.2 four_digit_year 4.;
run;
In the LINEAROPTs bundle for the X axis, specify INTEGER=TRUE.
In the LINEAROPTs bundle for the X axis, specify INTEGER=TRUE.
The easiest way is to add a YEAR4. format to your data (You currently are using the 4. format):
format FOUR_DIGIT_YEAR YEAR4.;
If you want to change the template, then go to the doc for the GTL axis options. and look at INTERVAL= option. You can use INTERVAL=YEAR if you are using the template for many data sets and are not sure that they will all have YEAR4 formats.
Dan just mentioned a good point: It depends on your data. (Thanks, Dan.) His way is correct if your data are raw numbers like 2000, 2001, 2002. My way assumed that you are using SAS date values, but you probably aren't or else you wouldn't be having this issue.
All of these solutions are nice. I went with Dan's.
Thanks I had a hard time figuring this one out.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.