Hi Everyone,
I'm trying to get both a subscript and a superscript onto a Unicode variable sigma. The sigma is irrelevant in this question, but I am curious how to add both a subscript and a superscript to the same character.
ods escapechar = '^';
p^{sub e(w)} <-this creates my p subscript e(w)
p^{super 2} <-this creates my p superscript 2 (or square)
How can I have these both placed on the same variable? I've tried combining them as follows:
p^{sub e(w)}^{super 2} <- I've tried this and many variations, but have not been successful in getting a result that looks correct. There are always gaps or spacing issues.
I'm thinking/hoping there is a command that handles this, but I have not been able to come across it yet. Any ideas/thoughts/solutions are greatly appreciated.
Thanks,
Chris
Hi,
Have you tried this:
ods escapechar='^';
ods html file='c:\temp\supersub.html';
title '^{unicode sigma}^{sub e(w)}^{super 1}';
proc print data=sashelp.class(obs=2);
run;
ods html close;
cynthia
I ran your code and got a result that left a space between the sigma character and the superscript, because of the width of the intervening subscript.
I don't know if the OP intended this, but are you aware of any expression that can place both the superscript and subscript to be adjacent to the main character?
Hi,
To me that is a question for Tech Support. SAS is just sending instructions to the browser or other destination. The superscripts and subscripts are being rendered by the browser or Word or PDF.
When I just type in Word, here's what I get:
To my eye, the 1 in the bottom 2 lines looks slightly farther than the 1 in the first line. But I typed them all the same way, in the same font and then used Word controls to do the super/sub.
And, when I use SAS with different scenarios, this is what I see:
So, again, the 1 in the 3rd and a5th lines looks "closer" than the superscript 1 in the other lines.
But what SAS sent to the HTML to be rendered in the browser is this:
and, as you can see, where I've highlighted, SAS sent exactly the same HTML commands for every superscript 1. So I suspect that this is a rendering issue -- having to do with fonts and browsers. If I send the exact same code to RTF, then in Word, the header looks like this:
...which is why I suspect this is a rendering issue and I don't know that there's anything you can do at the SAS side of things to impact the rendering.
cynthia
In response to @Cynthia_sas, this is what I had in mind. I produced it in Word using the equation editor. What you see below is the word doc saved to an htm file and converted to png for upload.
What I was hoping for is a way to "trick" SAS into sending code to produce this result, even though I am of the opinion that it's not currently there to be found. (In short, in addition to the ^{sub e(w)} and ^{super 2} directives, what I'd like is a ^{supersub 2;e(w)} directive.
Or if there were some sort of backspace directive implementable between the sub and super, one might produce this:
Hi Cynthia,
Thank you for the reply. Yes, I have tried that, but as Mkeintz has suggested, it leaves an unwanted space. Ideally, I would like for the subscript and the superscript to be directly adjacent to the sigma.
The solution that I came up with was to create the equations in an equation editor such as MathType and save them as .png files. Then I could insert the .png into the text of the report when necessary.
Another question I have is whether or not we can expand the radical sign so that an equation fits under the radical. I followed the exact procedure above to accomplish this as well, but it would be much simpler if SAS had a way to accomplish this.
Again, thank you for the reply and please let me know if you have any info on expanding the radical as well. If not, no biggie.
Thanks,
Chris
Hi:
I assume you mean something like this:
I used the unicode symbol 221A for the square root and then textdecoration=overline to put a line above.
Cynthia
Wow, that is perfect! One last question, would you happen to know how to create a fraction, vertically not horizontally (if that makes sense)?
Or would you be able to point me to a source where I can learn more about options like textdecoration?
Thank You,
Chris
Hi, by vertical fractions, I assume you mean the one I typed into the Word equation editor in this screen shot:
I don't know of a way to do the first type of fraction with one number above the other. The UNICODE symbols for fractions seem to be the standard 1/4, 1/2, 1/8, etc.
We teach a lot about style attributes in our Report Writing 1 class, which focuses on ODS, PROC REPORT and PROC TABULATE. Or you could look for user-group papers that discuss style attributes. The PROC TEMPLATE documentation has a comprehensive list of style attributes, but it is fairly dense. Searching on the forum might help. I learned about textdecoration from reading this paper: http://www2.sas.com/proceedings/sugi31/227-31.pdf and even though it was written for version 9.2 of SAS, it is still a very good paper.
cynthia
Cynthia,
Your advice and the information you have provided is greatly appreciated. I recently took the Report Writing 1 class and that provided a solid foundation for me to build off of, but I am still learning all of these very specific styling attributes through various sources. Thank you for your time.
Best,
Chris
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!
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.
Ready to level-up your skills? Choose your own adventure.