BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I've assigned a spreadsheet to a libname (libname f "xyz.xls") and am using a data step to read in 2 worksheets.

One of the columns starts off and is mostly numeric, but occationally has text in it. SAS brings it in as numeric.

I would like to read the column as text. Is there any way to override the default behaviour?

Thank You,
Richard Wright
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Richard...
If you're using the Libname Excel engine, you can specify the MIXED=YES option on the import. This will read the "mixed" type column as character data. There is a side effect that the use of the MIXED= option causes the Excel workbook to be in READONLY mode (according to the doc).

This option seems designed to do exactly what you want.
cynthia
deleted_user
Not applicable
Thanks, Cynthia.

I tried that and it didn't seem to work.

Maybe, I'll go back and try it again.

Right now, I've resorted to import with lots of options, but that seems to be doing the same thing. The problem seems to stem from text added after the number - it looks like SAS sees the number, the blank after the number and blows off the remaining text.

And I thought this was going to be a snap.
deleted_user
Not applicable
I revisited the MIXED=YES option and here's what I found:

I am trying to read two sheets:

SET ldrs.'timesheeting$'N(IN=t KEEP=_last_name first_name position__ Approvers_Position__ Approver_s_Name RENAME=(Approvers_Position__= certifiers_position__ Approver_s_Name=name_of_certifier))
ldrs.'100% ILS-CRS$'N(IN=p KEEP=_last_name first_name position__ certifiers_Position__ Name_of_Certifier);

If I run the SET statement as is, I generate an error message about position__ being defined as numeric and character.

If I comment out the second data set (100%), things run as (more or less) expected.
Cynthia_sas
SAS Super FREQ
Richard:
It may be time to contact Tech Support with help on this. My importing of spreadsheets is mostly limited to single worksheets....unless somebody else has an idea.
cynthia
deleted_user
Not applicable
I took care of it:
renamed the one var to pos1 and pos2 respectively and used a combination of in= processing and ifc(vtype()=) that seems to be doing the trick (although I am puzzled by one facet of this - but that's for another day).

Thanks for the help, Cynthia

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!

Discussion stats
  • 5 replies
  • 952 views
  • 0 likes
  • 2 in conversation