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

I would like assign superscripts to LSMEANS differences from multiple comparison tests.

I have different factors with 2-3-4 and 5 levels to be used.

Below an example with 5 treatments and the desired output. Different letters meaning significant difference.

Thanks in advance

Trt

_Trt

Probz

Adjp

 

Desired output

 

1

2

0.0043

0.043

 

Trt

superscripts

1

3

0.0572

0.5718

 

1

acde

1

4

0.1636

1.0000

 

2

b

1

5

0.0615

0.6146

 

3

cb

2

3

0.5194

1.0000

 

4

db

2

4

0.9288

1.0000

 

5

ecd

2

5

<0.0001

0.000

   

3

4

0,178

1.0000

   

3

5

0.8890

1.0000

   

4

5

0.4736

1.0000

   

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

This is one way to create such a value that will display in report:

 

ods escapechar='~';

data example;
  input super $;
  length str $ 50;
  str=cat('1','~{super ',super,'}');
datalines;
a
ab
abc
aef
;

 proc report data=example;
    columns str;
    define str / display;
 run;

The ODS escapechar sets a character that tells SAS that some commands involving appearance options will be used and the character will be followed by specific functions. Use something not commonly used in your programs for other puposeses. This character will need to be set for any session displaying these values. Make sure that your desired output value variable has spaces for the escapechar the braces { } the word super, the space, and the longest set of superscripts you expect to use.

 

Some warnings: It appears that frequently fonts are not defined with superscripts and may not display depending on the font used. It isn't impossible that some fonts display different characters than expected.

Other approaches could be used with adding UNICODE characters but I have so little success finding the actual code values that the SAS Unicode function, which might be the easiest way to build something, would want for specific values that I don't bother. If you attempt the unicode route your variable may need up to 5 or 6 "spaces" for each unicode character displayed.

View solution in original post

6 REPLIES 6
ballardw
Super User

Where exactly will these superscripts be displayed?

Not going to happen as the value in a data set so need some clue how you want to use this. Data set contents do not have any display properties such as super- or subscript, bold, underline, italic or what have you. Where they are to display can have a very significant effect on what needs to be done and possibly even the ODS destination(s) that are the target of these values.

 

It may also be necessary to have the rules involved in assigning these, especially since multiple values appear to be involved. Rule as in why does Trt=1 get acde and Trt=2 get b (and the others as well).

misterlas
Fluorite | Level 6

Thanks for your quick reply.

Please, you will find below another example with 5 trt. As previously mentioned, I would like to assign superscripts to identify if there are significant differences or not when comparing trt in 2x2 fashion. So in the example above (by the way the trt (1-5) are superscripted by the letters), trt 1-2 are not differentthey both have the same letter a. Trt 1-3 are different, so they have different letters (resp. a and c). Trt 1-4 are not different, so 4 has letter a as trt 1. Trt 1-5 are different so the have different letters (a vs. ecd). In this last cas, please note that the letters from trt 5 (ecd) come from other comparisons (2-5,3-5,4-5). Hope i made it clear. I would welcome any simple approach.

Thanks in advance.

Trt_TrtEstimationPr > |z|P aj.Desired output
120.034430.91821.0000 
13-1.3209<.0001<.0001 
14-0.80550.03040.30371a
15-1.4352<.0001<.00012ba
23-1.3553<.00010.00013c
24-0.83990.03200.32034dac
25-1.4696<.00010.00015ecd
340.51540.13801.0000 
35-0.11430.68341.0000 
45-0.62970.08910.8908 
ballardw
Super User

I repeat: Display Where? What procedure?

 

Approaches that might work in one procedure for a report may not work for a graph. The superscripting will not exist in a data set so cannot consider the "superscripting" as a modeling value.

misterlas
Fluorite | Level 6
Sorry for that. To print using proc report
ballardw
Super User

This is one way to create such a value that will display in report:

 

ods escapechar='~';

data example;
  input super $;
  length str $ 50;
  str=cat('1','~{super ',super,'}');
datalines;
a
ab
abc
aef
;

 proc report data=example;
    columns str;
    define str / display;
 run;

The ODS escapechar sets a character that tells SAS that some commands involving appearance options will be used and the character will be followed by specific functions. Use something not commonly used in your programs for other puposeses. This character will need to be set for any session displaying these values. Make sure that your desired output value variable has spaces for the escapechar the braces { } the word super, the space, and the longest set of superscripts you expect to use.

 

Some warnings: It appears that frequently fonts are not defined with superscripts and may not display depending on the font used. It isn't impossible that some fonts display different characters than expected.

Other approaches could be used with adding UNICODE characters but I have so little success finding the actual code values that the SAS Unicode function, which might be the easiest way to build something, would want for specific values that I don't bother. If you attempt the unicode route your variable may need up to 5 or 6 "spaces" for each unicode character displayed.

misterlas
Fluorite | Level 6

Hi, your code was successful. Much appreciated.

I was looking for the logic on how to get the letters from p-values. Fortunately I found that the options were available under lsmeans lines linestable:

lsmeans &var / ilink cl diff ADJUST=BON lines linestable ;
ods output  lsmeans=lsm  LSMLines=LSMLines2;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 1063 views
  • 1 like
  • 2 in conversation