BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

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

Rick_SAS
SAS Super FREQ

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.

Rick_SAS
SAS Super FREQ

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.

DavidPhillips2
Rhodochrosite | Level 12

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

 

Thanks I had a hard time figuring this one out.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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