BookmarkSubscribeRSS Feed
RameshChandraKeer
Calcite | Level 5

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,


2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

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.

ballardw
Super User

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 596 views
  • 0 likes
  • 3 in conversation