I am using proc import to read in an excel sheet generated by someone using R. One of the columns on the spreadsheet contains both text and some basic math symbols. I normally don’t have an issue reading in this type of data using proc import (SAS 9.4), but in this case “>” is being read in as “>”. When I look at the spreadsheet, it shows the “>” symbol. Any suggestions?
@andreas_lds wrote:
Usual rant: don't use excel to transfer data, but csv, so that you don't have to rely on proc import.
I didn't see the issue, when importing a xlsx-file created by excel. Maybe the problem is the way R creates the file.
Likely from the choice of R package(s) creating some flavor of HTML output instead of plain text (ASCII characters) for that character. It may look something like a ">" character in display but is not but a similar "standard" so that the symbol renders properly regardless of the font used for display of HTML.
You can use the TRANWRD function in a data step to replace the now revealed ">" with simple ASCII ">"
Usual rant: don't use excel to transfer data, but csv, so that you don't have to rely on proc import.
I didn't see the issue, when importing a xlsx-file created by excel. Maybe the problem is the way R creates the file.
@andreas_lds wrote:
Usual rant: don't use excel to transfer data, but csv, so that you don't have to rely on proc import.
I didn't see the issue, when importing a xlsx-file created by excel. Maybe the problem is the way R creates the file.
Likely from the choice of R package(s) creating some flavor of HTML output instead of plain text (ASCII characters) for that character. It may look something like a ">" character in display but is not but a similar "standard" so that the symbol renders properly regardless of the font used for display of HTML.
You can use the TRANWRD function in a data step to replace the now revealed ">" with simple ASCII ">"
Thank you @andreas_lds and @ballardw. I asked the person who provided the excel sheet to provide me with a csv file and that solved the problem -- likely because as @ballardw said, the csv file is ASCII. I will remember the TRANWRD function in case I encounter an excel sheet where I can't go back and ask the person to re-export.
Glad you could resolve this.
My particular related peeve is one of my data sources has what should be an apostrophe come in as "'" yes 5 characters. In the same data a different variable instead of apostrophe in what should be "Master's Degree" I can't even type as it includes a Euro sign and the Trademark symbol.
These values apparently come from a drop-down selection list in an application so are pretty consistent. I can write custom informats to fix these as I read these source files frequently.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.