BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

Hello.  Any help you can give is much appreciated.

I've successfully imported the 40 xlslx spreadsheets using the code I found on this communities website - program attached.

But, I'm unable to append them because I'm getting error messages that some variables are both character and numeric.

This happens with the date fields (formatted as short date in xlsx) which have some missing observations.

How do I get around this?  MIXED=YES gives me more date fields that come up as character than numeric.

Is it better to import as character or as numeric?

7 REPLIES 7
jcis7
Pyrite | Level 9

Thanks!  Uploaded SAS file because it wasn't pasting properly.

stat_sas
Ammonite | Level 13

While importing excel files some of the variables may contain missing values in the first row that creates a problem. PROC IMPORT with an Excel file, uses the first eight lines to determine if a variable is numeric or character. So importing csv files will provide more flexibility. You can put GUESSINGROWS =  (max number of rows to be examined) option in proc import to determine the exact variable type.


Regards,

Naeem

ballardw
Super User

And you probably want to start with the code you used to import the data.

The quickest fix might end up making changes in the Excel data or exporting the data to CSV and reading that with more control than proc import gives, such as control over whether a variable is numeric or character, associated formats and use of appropriate informats.

jcis7
Pyrite | Level 9

I highlighted all the date columns in each Excel spreadsheet and changed them to 'short date' but still unable to import the fields (esp ones with more missing values) as numeric.

I can try to export into CSV and import into SAS unless you suggest anything else?

agoldma
Pyrite | Level 9

If you want PROC IMPORT to have an option to import all fields as character, please vote:

PROC IMPORT -- all fields as character

agoldma
Pyrite | Level 9

If you want PROC IMPORT to have an option to import all fields as character, please vote:

PROC IMPORT -- all fields as character

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 2899 views
  • 2 likes
  • 5 in conversation