How to mantain data type while importing data from Excel sheet?

Reply
Occasional Contributor
Posts: 6

How to mantain data type while importing data from Excel sheet?

Hi All,

I am importing an Excel file data into a Sas data set.

Excel file has basically two columns one with numeric data type and one with character data. In few files both are numeric or both character too.

But in Sas data set it always coming as charecter data type. My requirement is if it's numeric in Excel than it should be Numeric in Sas data and if it's Charecter than it should charecter in Sas data after imported.

Any suggestion???

Thank,


Super Contributor
Posts: 1,636

Re: How to mantain data type while importing data from Excel sheet?

Posted in reply to RameshChandraKeer

Hi,

SAS imports as character because there are both numeric and character cells in the same column of your Excel file. If you clear the format of your excel file you would see all the character cells moving to the right.

Super User
Posts: 11,343

Re: How to mantain data type while importing data from Excel sheet?

Posted in reply to RameshChandraKeer

Longer but you have more control is to save the Excel file as CSV and then import that. There will be data step code generated in the log that can be copied and modified to provide much more control than proc import allows for excel files such as custom informats, length of character variables, assigning labels. Also additional calculations or custom warnings for data ranges can be added to the code.

Since I deal with entry people who will type 'Missing' into a cell that is supposed to be numeric or a value plus text such as "100 weekly" I find this approach more effective in the long run.

Ask a Question
Discussion stats
  • 2 replies
  • 207 views
  • 0 likes
  • 3 in conversation