BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11
symbol1 pointlabel = ("#N" h=.5 font=simplex nodropcollisions) value=none;

N is a number of cases.  I'd like to see that number as label in a scatterplot, instead of a dot.

 

proc gplot data=have;
plot X * Y = 1;  /* Surmised that "= 1" means symbol1 */ 
run;
quit;

Unfortunately N shows in the plot having many decimal places, all 0.

 

I figured using int() would do the trick, to just show N alone, no superfluous unwanted decimal places.

 

I tried several ways, but none seem to work.  One approach that does not work is:

 

"#int(N)"

Another possibility would be to create an ad-hoc variable, N2, that is int(N), and then to use N2 instead of N in the pointlabel.  But I'm not sure how to code such.

 

Any help toward a solution greatly appreciated.

 

Nicholas Kormanik

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Use the FORMAT statement:

 

proc sgplot data=Have;
format N f2.0; scatter x=x y=y / markerchar=N markercharattrs=(size=14); run;

View solution in original post

6 REPLIES 6
Rick_SAS
SAS Super FREQ

Would you be willing to use PROC SGPLOT instead?  If so, you can use the MARKERCHAR= option to specify a variable name. Instead of markers, the value of that variable is plotted. You can controls the size and color of the text by using the MARKERCHARATTRS= option:

 

data Have;
input x y N;
datalines;
1 2 37
3 1 23
5 2 16
4 1  2
5 4  1
3 3 18
;

proc sgplot data=Have;
scatter x=x y=y / markerchar=N markercharattrs=(size=14);
run;
NKormanik
Barite | Level 11

Beautiful.  Still, however, all those .000000 after each number in plot.

 

Got error message when I tried:  

 

markerchar=int(N)

 

and

 

markerchar=(int(N))

 

Perhaps I should format the N column itself?

 

Thanks much!

 

 

Jay54
Meteorite | Level 14

Yes, apply the format to the column.  If you don't want decimals, use the x.0 format.  If you review the doc, you will see that MARKERCHAR only accepts a variable, not an expression.  If you want to use expressions, use GTL.

NKormanik
Barite | Level 11

What's the easiest way to apply that format to the column?

 

 

DanH_sas
SAS Super FREQ

Use the FORMAT statement:

 

proc sgplot data=Have;
format N f2.0; scatter x=x y=y / markerchar=N markercharattrs=(size=14); run;
NKormanik
Barite | Level 11

Excellent.  This approach has the added benefit of not having to affect/rewrite the dataset.

 

Thanks much to all of you!

 

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1985 views
  • 2 likes
  • 4 in conversation