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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 1146 views
  • 1 like
  • 2 in conversation