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

I would like to mark one of the bars in a bar chart with a star (in this example I am looking to star the value of order=4). I have found many examples of putting a significance star somewhere on the bar but would like one under the bar in place of where the value for the x axis would go. I have done this in proc gchart utilizing the xaxis statement (value=(f=marker color=blue t=4 "V")), but have not found a solution for sgplot. Any help would be appreciated. Using SAS 9.4.

 

Current code:

data have;
input order evalelbw barlabel;
datalines;
1 24 .
2 43 .
3 48 .
4 54 1
5 56 .
6 57 .
7 65 .
8 73 .
9 77 .
10 91 .
11 100 .
;
run;
proc sgplot data=have noautolegend;
vbar order/response=evalelbw;
yaxis grid values=(0 to 100 by 10) offsetmax=0.02 label="%";
xaxis display=(nolabel noticks novalues);
run;
quit;

This is what I am looking for:

graph want.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

One way that works with your example data.

 

proc format;
value barlabel
1 = '*'
other=' '
;
run;
proc sgplot data=have noautolegend;
vbar order/response=evalelbw;
yaxis grid values=(0 to 100 by 10) offsetmax=0.02 label="%";
xaxis display=(nolabel noticks novalues );
xaxistable barlabel / nolabel nostatlabel valueattrs=(size=15pt);
format barlabel barlabel.;
run;



You could the format to assign more interesting symbols with unicode (and *ESC* ) or specify a symbol font using the Family optiion in the Valueattrs combined with Format

View solution in original post

6 REPLIES 6
ballardw
Super User

One way that works with your example data.

 

proc format;
value barlabel
1 = '*'
other=' '
;
run;
proc sgplot data=have noautolegend;
vbar order/response=evalelbw;
yaxis grid values=(0 to 100 by 10) offsetmax=0.02 label="%";
xaxis display=(nolabel noticks novalues );
xaxistable barlabel / nolabel nostatlabel valueattrs=(size=15pt);
format barlabel barlabel.;
run;



You could the format to assign more interesting symbols with unicode (and *ESC* ) or specify a symbol font using the Family optiion in the Valueattrs combined with Format

kmorrowvt
Obsidian | Level 7

Thank you. In trying to get something fancier, I tried to use the marker font, but I'm only getting the character rather than it transforming to the appropriate symbol. Am I missing something? (I tried assigning the barlabel to V directly in the data and by setting it to V with proc format.)

data have;
   input order evalelbw barlabel $;
   datalines;
1 24 .
2 43 .
3 48 .
4 54 V
5 56 .
6 57 .
7 65 .
8 73 .
9 77 .
10 91 .
11 100 .
;
run; 

  proc sgplot data=have noautolegend;
	  vbar order/response=evalelbw;
		yaxis grid values=(0 to 100 by 10) offsetmax=0.02 label="%";
		xaxis display=(nolabel noticks novalues);
    xaxistable barlabel / nolabel nostatlabel valueattrs=(family=Marker size=15);
	run;
	quit;
ballardw
Super User

@kmorrowvt wrote:

Thank you. In trying to get something fancier, I tried to use the marker font, but I'm only getting the character rather than it transforming to the appropriate symbol. Am I missing something? (I tried assigning the barlabel to V directly in the data and by setting it to V with proc format.)it;


I haven't used the Marker fonts since the time I was using SAS 6.12 or so. The few times I looked at such with the ODS destinations have all been pretty much a bust. Either I am not getting the actual name correctly or the font isn't a True Type and ODS doesn't like it or something. Hopefully someone else may have an idea.

 

If you were getting what looked like an empty box in the output that is what I had as well when I made a short attempt to use the marker font.

kmorrowvt
Obsidian | Level 7

Yeah, I am getting the empty box when trying to do anything with unicode 2605 and only a "V" when trying to apply the marker font. 

FreelanceReinh
Jade | Level 19

Hello @kmorrowvt,


@kmorrowvt wrote:

Yeah, I am getting the empty box when trying to do anything with unicode 2605 ...


You may need to activate DBCS to get the star symbol from Unicode 2605. Even in a SAS session "with Unicode support" I got the "empty box" character, but with "SAS 9.4 (English with DBCS)," i.e., a config file containing a certain set of system options, I was able to reproduce Ksharp's graph. (Using a local SAS 9.4M5 installation under Windows.)

Ksharp
Super User
data have;
input order evalelbw barlabel;
datalines;
1 24 .
2 43 .
3 48 .
4 54 1
5 56 .
6 57 .
7 65 .
8 73 .
9 77 .
10 91 .
11 100 .
;
run;
proc sgplot data=have noautolegend;
vbar order/response=evalelbw;
yaxis grid values=(0 to 100 by 10) offsetmax=0.02 label="%";
xaxis display=(nolabel noticks ) values=(1 to 11 by 1) 
valuesdisplay=(''  ''  ''  "(*ESC*){unicode '2605'x}" '' '' '' '' '' '' '' ) ;
run;
quit;

Ksharp_0-1646476296227.png

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1392 views
  • 5 likes
  • 4 in conversation