BookmarkSubscribeRSS Feed
Samasim
Calcite | Level 5

I'm running this code in SAS:

* Series plot;
PROC SGPLOT DATA = UsGR;
SERIES X = Year Y = Overall_RBC /lineattrs =(color=red thickness =2pt);
SERIES X = Year Y = New/lineattrs =(color=blue thickness =2pt);
SERIES X = Year Y = Existing/lineattrs =(color=green thickness =2pt);
SERIES X = Year Y = Replace/lineattrs =(color=purple thickness =2pt);
XAXIS TYPE = Discrete labelattrs=(size=2);
XAXIS values =(1953 to 2016 by 2);
YAXIS LABEL = 'RBC Score';
title 'U.S. Decomposition';
RUN;

 

It gives me the graph I want however on the x-axis I want minor tick marks between the years (i.e 1953 (a tick mark for 1954) 1955 etc.  Also I want all my  xaxis years to be horizontal not slanted labels.  I would also like to have textbox (legend) in the topleft  if it can be done that looks like this:

Samasim_0-1673569236215.png

Thanks!

3 REPLIES 3
GraphGuy
Meteorite | Level 14

Can you attach an example of what your graph looks like?

DanH_sas
SAS Super FREQ

Setting TYPE-DISCRETE on the X axis will prevent you from displaying any axis minor tick values, as minor ticks are not applicable in that case.

If your "year" data is in date time format, remove the TYPE=DISCRETE and set INTERVAL=YEAR and MINOR.

If your "year" data is just a double column, remove the TYPE=DISCRETE and set INTEGER and MINOR.

 

Let me know if either of these work for you.

ballardw
Super User

" I would also like to have textbox (legend) in the topleft if it can be done that looks like this".

This would be an INSET such as below:

proc sgplot data=sashelp.class;
   scatter x=height y=height;
   inset  "Line 1 of inset text"
          "Line 2 of inset text"
          "Line 3 of inset text"
         /title='This is title for inset box'
   ;
run;
         

You show a picture that I am too lazy to type. There are options to specify text appearance and location options. The default is upper left inside the graph area.

 

LEGENDS are something completely different and describe such things as line color/type or marker meanings.

 

 

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
  • 3 replies
  • 576 views
  • 0 likes
  • 4 in conversation