Data visualization with SAS programming

Formatting X-Axis with SG Render

Accepted Solution Solved
Reply
Super Contributor
Posts: 465
Accepted Solution

Formatting X-Axis with SG Render

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;

 

 


Accepted Solutions
Solution
‎02-05-2016 02:10 PM
SAS Super FREQ
Posts: 889

Re: Formatting X-Axis with SG Render

In the LINEAROPTs bundle for the X axis, specify INTEGER=TRUE.

View solution in original post


All Replies
Solution
‎02-05-2016 02:10 PM
SAS Super FREQ
Posts: 889

Re: Formatting X-Axis with SG Render

In the LINEAROPTs bundle for the X axis, specify INTEGER=TRUE.

SAS Super FREQ
Posts: 3,406

Re: Formatting X-Axis with SG Render

[ Edited ]

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.

SAS Super FREQ
Posts: 3,406

Re: Formatting X-Axis with SG Render

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.

Super Contributor
Posts: 465

Re: Formatting X-Axis with SG Render

All of these solutions are nice.  I went with Dan's.

 

Thanks I had a hard time figuring this one out.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 408 views
  • 3 likes
  • 3 in conversation