My poor colleague was pulling her hair out in frustration today.
You know when you’re trying to do something quickly, and it’s supposed to be easy, only it’s not? And you try every solution you can think of and it still doesn’t work?
And even in the great age of the Internet, which is supposed to know all the things you don’t, you still can’t find the answer anywhere?
Here’s what happened: She was trying to import an Excel spreadsheet into SAS, and it didn’t work.
Instead she got:
Look familiar? If you’re like my colleague, you’re wondering, what the blank is going on here?
Well, if you have SAS 64-bit and Office 32-bit (or even Office 64-bit), you’ll find that the 64-bit version of SAS does not have the interface to communicate with Office and therefore cannot import spreadsheets.
Yep, you read that right: it can’t do it through the wizard and it can’t do it through Proc Import.
So here’s what you have to do.
Save the Excel spreadsheet as a .csv file, and then import it. (You can only have 1 worksheet in the .csv file, but other than that, you shouldn’t see any differences from an Excel spreadsheet.)
It should look like this:
PROC IMPORT OUT= WORK.QA *desired filename;
DATAFILE= “C:\file to import”
DBMS=CSV REPLACE; guessingrows=1000;
BTW, the guessingrows option is very useful: it tells SAS to read through the specified number of lines (the limit is 214,7483,647 and the default is 20) to determine the length of variables.
Without this option, if the first 20 values are 2 characters and the 21st is 3 characters, your values will be truncated. Specifying the guessingrows (you can just use guessingrows=Max) ensures that SAS looks at all the values in your dataset (i.e., all rows) before it sets the length of variables.
So spread the word. And save your hair.
Life will be easier if everyone starts using .csv files instead of Excel files.