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

I am using the SGPLOT procedure to create statistical plot. I have three columns in my YAXISTABLE, yet I only want to italicize one of them. Is there any way to do so?

Moreover, is it possible to italicize one character of the label of YAXISTABLE while keeping the rest of the characters (i.e., all the remaining characters in the three labels) normal?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Without seeing your code, I'm guessing that you are putting all three columns on the same YAXISTABLE statement. For this case, put each column on it's own YAXISTABLE statement, and order the statements to get the column order you want. Then, on the statement containing the column you want italicized , set VALUEATTRS=(style=italic).

 

As for the italic single character in the label,, unfortunately your only option would be to use annotation text for the label.

 

Hope this helps!

View solution in original post

14 REPLIES 14
quickbluefish
Barite | Level 11
You could MAYBE do 3 separate YAXISTABLE statements (one for each column) and position them next to each other. As for italicizing a single character - I really doubt that could be done with SGPLOT.
Season
Barite | Level 11

Thank you! It feels great seeing you once again as a solution provider. Your method of creating three different YAXISTABLE statements works perfectly!

DanH_sas
SAS Super FREQ

Without seeing your code, I'm guessing that you are putting all three columns on the same YAXISTABLE statement. For this case, put each column on it's own YAXISTABLE statement, and order the statements to get the column order you want. Then, on the statement containing the column you want italicized , set VALUEATTRS=(style=italic).

 

As for the italic single character in the label,, unfortunately your only option would be to use annotation text for the label.

 

Hope this helps!

Season
Barite | Level 11

Thank you for your reply! Yes, you are right. I did put three columns in one YAXISTABLE statement. Separating them into multiple statements worked perfectly!

I would like to further raise two questions:

(1) Could you please give me advice or hints on how to annotate so that one single character can be italicized while all other characters remain normal? I tried the ODS ESCAPECHAR statement and found that it did not work here, despite its excellent performance in handling texts in procedures like the REPORT procedure. I had read some examples on using datasets for annotation in the SGPLOT procedure, but I have not found examples that italicize a single character by using dataset-assisted annotation. I wonder if this is possible.

(2) Is there a way of formatting the contents of the YAXISTABLE? I have all observations retained up to four decimal places except one that only retains two, for the observation's latter two digits are both zero (something like 0.5800). I wish to format them to 8.4, but the VALUEATTRS option in the YAXISTABLE statement does not seem to support such formatting. It seems that only text attributes like word size, font and whether the words are italicized are modifiable with that option.

Thank you!

ballardw
Super User

First will reiterate: Show the code you are currently using and clearly describe exactly what "label" is to be used where.

 

Here is an example with using UNICODE values inserted as a group label in an axis table:

https://communities.sas.com/t5/Graphics-Programming/Adding-greater-than-or-equal-to-symbol-in-XAXIST...

So if you can find a unicode character that matches your italicized single character it may be one approach.

Season
Barite | Level 11

Thank you for your reply. But I do not see any need to provide my original code here now that the first question I raised yesterday has been settled. As a SAS user that has been using this software for years, I know where my problem lies and I can, and have made myself clear enough by extracting the specific issue I concern about without having to let others take more time to read my code and understand my entire project.  On the other hand, I will post my code if I think that details of the project must be put into context so that others can come up with a solution to the programming problem I encountered. Take a look at my posts in the SAS/IML section of the Community last month. I did post my codes by then because I thought it necessary.

Quentin
Super User

@Season wrote:

Thank you for your reply. But I do not see any need to provide my original code here now that the first question I raised yesterday has been settled. As a SAS user that has been using this software for years, I know where my problem lies and I can, and have made myself clear enough by extracting the specific issue I concern about without having to let others take more time to read my code and understand my entire project.  On the other hand, I will post my code if I think that details of the project must be put into context so that others can come up with a solution to the programming problem I encountered. Take a look at my posts in the SAS/IML section of the Community last month. I did post my codes by then because I thought it necessary.


It's *always* helpful to include simplified example code (and example data) in a question.  Both to provide an understanding of the question, and to provide your potential helpers with sample code/data so they can jump in and try something, without having to create sample data/code themselves.  Also helpful for future folks who will google this problem and find a post.  If I find an accepted solution that has example data and code, that's a huge win.  If I find accepted solution where there are words to describe the problem, and words to describe a solution, it's much less helpful.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Lisa Mendez & Richann Watson present Get Tipsy with Debugging Tips for SAS® Code: The After Party on Wednesday Jul 16.
Register now at https://www.basug.org/events.
DanH_sas
SAS Super FREQ

1) To create a rich-text string like you want, you will need to use a combination of the TEXT and TEXTCONT functions. Look at my paper on SG annotation starting at the end of page 13. You will see an example that uses TEXT and TEXTCONT to create a rich-text string. Basically, you will use TEXT to set the position of the string, along with writing the first character as Italic. You will also need to set the background to be filled with the same color as your background to blank out the other text. Then, use TEXTCONT to write out the rest of the string as "normal" text.

 

2) In the procedure, you should be able to use the FORMAT statement to change the format of the column used in the YAXISTABLE.

Season
Barite | Level 11

(1) Thank you very much for kindly introducing your paper! I read your example on page 14 of your paper (the one demonstrating how to put the sentence "These cars are VERY expensive!" in a plot with arrows) and have come to know how to assign different portions of a sentence with different appearances. But the question lingers on the variable name used for designating whether a string is italicized or not. I learnt from your code that the variable in charge of the string's color is called "textcolor". So what about the one responsible for italicization of strings?

(2) Thank you for your reply! Like many SAS procedures, the FORMAT statement is not demonstrated in the SAS documentation, but it is still in effect. I therefore completely forgot this when I was raising this question. It works perfectly well to add the code of

format a 8.4;

to let the variable named a display four decimal places in the plot. Thank you!

DanH_sas
SAS Super FREQ

The column you want is TEXTSTYLE. If you were going to write the word "Average", you would first use the TEXT function, with LABEL="A" and TEXTSTYLE="italic". Then, use the TEXTCONT function with LABEL="average" and TEXTSTYLE="normal". Don't forget to set FILLCOLOR to be your background color to blank out the other text.

Season
Barite | Level 11

Thank you again for your answer!


@DanH_sas wrote:

The column you want is TEXTSTYLE. If you were going to write the word "Average", you would first use the TEXT function, with LABEL="A" and TEXTSTYLE="italic". Then, use the TEXTCONT function with LABEL="average" and TEXTSTYLE="normal". 


But with no intention of being meticulous or fussy on trivial issues, I beg to ask whether there is a small mistake in the designation of the second LABEL. Should that be "verage" to avoid double a's in the resultant string shown on the plot?

quickbluefish
Barite | Level 11
Wow, that POLYLINE thing on p. 16 is great - I've never seen that before. I've made those kinds of brackets connecting different parts of a plot by building the shape with several vector statements, but it's incredibly awkward that way - this is perfect!
DanH_sas
SAS Super FREQ

Glad that example helps you 🙂 This paper was written back in 2011. Since that time, there are several examples in the paper that can now be done using just regular options (your example is not one of them), but at least they still demonstrate the capabilities of the annotation system.

Season
Barite | Level 11

I am also glad that my questions somewhat benefit you and provide you with excitement by prompting your encounter with this nice paper. It is also a wonderful experience for me.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 14 replies
  • 2710 views
  • 6 likes
  • 5 in conversation