BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DmytroYermak
Lapis Lazuli | Level 10

Hi all,

I need to extend keyleged with some text. Can you please help with options? Here it is an example and the proc sgplot code:

data WORK.Density;
  infile datalines dsd truncover;
  input GROUP:$200. LEVEL:32. LEVELC:$200. X:32.;
  label LEVEL="Level";
datalines4;
Density A,1,Level 1,18.168377823
Density A,1,Level 1,18.694045175
Density A,1,Level 1,21.158110883
Density A,1,Level 1,24.443531828
Density A,1,Level 1,27.86036961
Density A,2,Level 2,18.234086242
Density A,2,Level 2,18.759753593
Density A,2,Level 2,21.437371663
Density A,2,Level 2,24.410677618
Density A,2,Level 2,28.090349076
Density A,3,Level 3,19.811088296
Density A,3,Level 3,23.72073922
Density A,3,Level 3,29.32238193
Density A,3,Level 3,30.094455852
Density A,3,Level 3,32.755646817
Density A,4,Level 4,21.190965092
Density A,4,Level 4,24.082135524
Density A,4,Level 4,31.835728953
Density A,4,Level 4,33.281314168
Density A,4,Level 4,40.213552361
Density A,5,Level 5,21.815195072
Density A,5,Level 5,27.564681725
Density A,5,Level 5,31.770020534
Density A,5,Level 5,34.891170431
Density A,5,Level 5,40.509240246
Density A,6,Level 6,25.757700205
Density A,6,Level 6,31.901437372
Density A,6,Level 6,38.636550308
Density A,6,Level 6,43.466119097
Density A,6,Level 6,53.420944559
Density B,1,Level 1,18
Density B,1,Level 1,18
Density B,1,Level 1,18
Density B,1,Level 1,20
Density B,1,Level 1,26
Density B,2,Level 2,18
Density B,2,Level 2,18
Density B,2,Level 2,18
Density B,2,Level 2,26.5
Density B,2,Level 2,32.8
Density B,3,Level 3,18
Density B,3,Level 3,22.5
Density B,3,Level 3,28
Density B,3,Level 3,29.5
Density B,3,Level 3,32.2
Density B,4,Level 4,22
Density B,4,Level 4,26.5
Density B,4,Level 4,29.5
Density B,4,Level 4,31.3
Density B,4,Level 4,33.1
Density B,5,Level 5,25
Density B,5,Level 5,28.5
Density B,5,Level 5,31
Density B,5,Level 5,34
Density B,5,Level 5,35.2
Density B,6,Level 6,27.7
Density B,6,Level 6,31
Density B,6,Level 6,33.5
Density B,6,Level 6,36
Density B,6,Level 6,36.4
Density A,0,Level 0,77.141683778
Density A,0,Level 0,77.141683778
Density A,0,Level 0,77.141683778
Density A,0,Level 0,77.141683778
Density A,0,Level 0,77.141683778
Density A,1,Level 1,23.490759754
Density A,1,Level 1,26.349075975
Density A,1,Level 1,60.747433265
Density A,1,Level 1,66.234086242
Density A,1,Level 1,74.05338809
Density A,2,Level 2,51.909650924
Density A,2,Level 2,56.016427105
Density A,2,Level 2,68.238193018
Density A,2,Level 2,75.531827515
Density A,2,Level 2,86.308008214
Density A,3,Level 3,68.238193018
Density A,3,Level 3,68.238193018
Density A,3,Level 3,68.238193018
Density A,3,Level 3,68.238193018
Density A,3,Level 3,68.238193018
Density A,4,Level 4,54.899383984
Density A,4,Level 4,57.708418891
Density A,4,Level 4,68.041067762
Density A,4,Level 4,95.211498973
Density A,4,Level 4,114.85831622
Density A,5,Level 5,70.472279261
Density A,5,Level 5,75.86036961
Density A,5,Level 5,80.854209446
Density A,5,Level 5,98.825462012
Density A,5,Level 5,122.21765914
Density A,6,Level 6,68.468172485
Density A,6,Level 6,83.482546201
Density A,6,Level 6,104.11498973
Density A,6,Level 6,127.17864476
Density A,6,Level 6,184.41067762
Density B,1,Level 1,42
Density B,1,Level 1,47
Density B,1,Level 1,64.5
Density B,1,Level 1,92
Density B,1,Level 1,150.5
Density B,2,Level 2,62.6
Density B,2,Level 2,72.3
Density B,2,Level 2,91
Density B,2,Level 2,114.8
Density B,2,Level 2,166.4
Density B,5,Level 5,63.8
Density B,5,Level 5,78
Density B,5,Level 5,96
Density B,5,Level 5,157
Density B,5,Level 5,188.4
Density B,6,Level 6,68
Density B,6,Level 6,84.8
Density B,6,Level 6,116
Density B,6,Level 6,159
Density B,6,Level 6,227
;;;;

run;

%let attrs=thickness=2px;
proc sgplot data=a1 noautolegend;
  styleattrs datacontrastcolors=(gray CXE2B977) datalinepatterns=(1 1);
  yaxis       label="Level";
  xaxis min=0 label="Units X";
  hbox x / category=levelc whiskerpct=0 nomean nofill group=group
           lineattrs   =(&attrs)
           medianattrs =(&attrs)
           whiskerattrs=(&attrs)
           name= "box";
  keylegend "box"  / noborder location=outside position=bottom ; 
run;

Here it is the result:

Untitled.jpg

But I need some more text to be added into keylegend (underlined red):

Untitled2.jpg

I tried to use LEGENDITEM but failed.

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Use PROC FORMAT to create a custom format That will map "Density A" to "Density A (N=115)[1]" and the same for the other density groups.

 

Hope this helps!

Dan

View solution in original post

1 REPLY 1
DanH_sas
SAS Super FREQ

Use PROC FORMAT to create a custom format That will map "Density A" to "Density A (N=115)[1]" and the same for the other density groups.

 

Hope this helps!

Dan

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1 reply
  • 843 views
  • 1 like
  • 2 in conversation