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

I need to create a plot with MY2R values in the symbol center. But even I used DATALABELPOS=CENTER, all the data labels shift to right and not in the center. Could someone please help me with it? Thanks. 

 

Here is my code:


PROC SGPLOT DATA = temp1 dattrmap=attrmap noborder;


Scatter Y=NAME X = MY2R/markerAttrs=(COLOR=purple size=6MM symbol=CIRCLEFILLED)  datalabel=MY2R DATALABELATTRS=(size=9pt weight=bold COLOR=White) DATALABELPOS=CENTER transparency=0.1;

 

XAXIS DISPLAY=(NOTICKS) label=' ' labelattrs=(size=8pt color=Black) values=(60 to 100 by 20) valueattrs=(size=8pt Family=Arial color=black); 

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Make sure you do not have leading blanks in your labels.  Also, you can use a TEXT plot to display labels with the STRIP option.

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

Make sure you do not have leading blanks in your labels.  Also, you can use a TEXT plot to display labels with the STRIP option.

WarrenKuhfeld
Rhodochrosite | Level 12

Following up on @Jay54, these steps illustrate a character variable (centered), a numeric variable (and hence leading blanks) (does not appear centered), and a numeric to character conversion and left justification before plotting (centered).

proc sgplot data=sashelp.class;
   scatter y=weight x=height / datalabel=name datalabelpos=center;
quit;

proc sgplot data=sashelp.class;
   scatter y=weight x=height / datalabel=age datalabelpos=center;
quit;

data class;
   set sashelp.class;
   age2 = cats(age);
run;   

proc sgplot data=class;
   scatter y=weight x=height / datalabel=age2 datalabelpos=center;
quit;
hanyi0221
Fluorite | Level 6

Thank you Warren, this is very helpful and I will save your post as future reference.

hanyi0221
Fluorite | Level 6

Thank you Sanjay! My labels do have leading blanks.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3385 views
  • 1 like
  • 3 in conversation