BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Anita_n
Pyrite | Level 9

if I have on the xaxis a list of years like 2001-2010 and I want to display for example between each year months 1-12 as interval. How can I do this? I used something like minor minorcount=12, which quiet displays the 12 ticks between the years but the plot isn't showing. Maybe am doing something wrong. Any help?

 

data have;
set sashelp.countseries;
format month_year mmyyn6.;
month_year=date;
where units in (0, 2, 3, 4);
run;


proc sgplot data=have;
scatter y=units x=month_year /markerattrs=(symbol=trianglefilled size=8 color=red );
xaxis label='years' values=(2004 to 2012 by 1) minor minorcount=12; 
run;

For example if the value of month_year=042004. I will like the plot to start on the fourth minor tick between 2004 and 2005

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You don't need to convert the 'date' variable to anything. PROC SGPLOT knows how to plot dates. 

If you want major tick marks to indicate January, there are 11 minor tick marks (not 12) between the major ticks.

You can use the MIN= option on the XAXIS statement to specify the minimum value of an axis. For a date variable, you could use something like MIN='01Apr2004'd

 

data have;
set sashelp.countseries;
where units in (0, 2, 3, 4);
run;

proc sgplot data=have;
scatter y=units x=date /markerattrs=(symbol=trianglefilled size=8 color=red );
xaxis label='years' minor minorcount=11 min='01Apr2004'd; 
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

You don't need to convert the 'date' variable to anything. PROC SGPLOT knows how to plot dates. 

If you want major tick marks to indicate January, there are 11 minor tick marks (not 12) between the major ticks.

You can use the MIN= option on the XAXIS statement to specify the minimum value of an axis. For a date variable, you could use something like MIN='01Apr2004'd

 

data have;
set sashelp.countseries;
where units in (0, 2, 3, 4);
run;

proc sgplot data=have;
scatter y=units x=date /markerattrs=(symbol=trianglefilled size=8 color=red );
xaxis label='years' minor minorcount=11 min='01Apr2004'd; 
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1644 views
  • 1 like
  • 2 in conversation