Greetings,
I'm in the process of importing character variables from an Excel file, and I've observed that SAS doesn't carry over the formatting from Excel. For instance, text formatted as bold in Excel appears as plain text after importing. I considered the possibility of modifying the data within Excel in a manner that would prompt SAS to automatically apply formatting (like using asterisks in Excel to indicate text that should be imported as bold into SAS). However, I haven't come across any information regarding this approach. Is there a method to import the applied formatting along with the data?
Best regards
Do you mean you want bold in Excel to show us as bold in SAS? There is no such thing as bold text in a SAS data set.
Well yes, that is more or less what I am talking about. As far as I know, it is possible to change the font format inside of a proc step (e. g. proc report). But as I am preparing my data in Excel I was hoping that there is an easier way than writing separate code for every single word that needs to be bold or underlined.
Kind regards
@Jakobsen96 wrote:
Well yes, that is more or less what I am talking about. As far as I know, it is possible to change the font format inside of a proc step (e. g. proc report). But as I am preparing my data in Excel I was hoping that there is an easier way than writing separate code for every single word that needs to be bold or underlined.
PROC REPORT and PROC TABULATE (and possibly a few other PROCs that I can't think of right now) allow bold output. I am not aware of a way for SAS to know that certain text or numbers it just read from Excel was bold in Excel.
@Jakobsen96 wrote:
Well yes, that is more or less what I am talking about. As far as I know, it is possible to change the font format inside of a proc step (e. g. proc report). But as I am preparing my data in Excel I was hoping that there is an easier way than writing separate code for every single word that needs to be bold or underlined.
Kind regards
To a certain extent all of that cell level, if not just part of cell, formatting is inappropriate for any data system that sets properties on a variable ("column") level. Microsoft SQL Server and Access data bases do not maintain such.
Without explicit examples it is hard to make appropriate suggestions but I have received files where cell level formatting, cell background color, for example contains information that belongs in another variable, such as a condition flag value to indicate that information.
A character variable in SAS is just a sequence of bytes. There is no place in the header of a dataset to store fonts or the like.
No.
If you want to see how Excel is storing that information you could try unpacking the zipped XML files that make up an XLSX file. You could perhaps write your own method of extracting the text with whatever markup characters Excel has stored to make it possible for excel to change fonts, colors, etc.
Or you could have Excel write the data to an HTML file and then try to parse the HTML code for the text of interest and see what html codes Excel generated to mimic the text markups.
In terms of reproducing such mid string changes in text you will have to store ODS escape sequences into the text strings. Then when you print the values using ODS output (to say EXCEL or HTML of PDF files) then you might be able to recreate the appearance of the text in the EXCEL file.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.