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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 374 views
  • 0 likes
  • 3 in conversation