BookmarkSubscribeRSS Feed
chjones
Calcite | Level 5

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

 

 

9 REPLIES 9
Cynthia_sas
SAS Super FREQ

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

mkeintz
PROC Star

@Cynthia_sas

 

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?

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Cynthia_sas
SAS Super FREQ

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:

word_super_sub.png

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:

super_sub.png

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:what_in_html.png

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:

same_code_to_Word.png

...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

mkeintz
PROC Star

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:

 

σew2.png

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
chjones
Calcite | Level 5

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

Cynthia_sas
SAS Super FREQ

Hi:

  I assume you mean something like this: square_root.png

I used the unicode symbol 221A for the square root and then textdecoration=overline to put a line above.

 

Cynthia

chjones
Calcite | Level 5

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

Cynthia_sas
SAS Super FREQ

Hi, by vertical fractions, I assume you mean the one I typed into the Word equation editor in this screen shot:

fractions.png

 

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

 

 

chjones
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 9 replies
  • 19904 views
  • 1 like
  • 3 in conversation