BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

I tried to import the attached xlsx file; in the HOLNO column, most of the data were imported except the last row which is in character format. 

 

I would like to import the HOLNO column as character format wihout modifying the excel file. 

 

Anyone can help? Thanks.

 

My code:

PROC IMPORT DATAFILE="D:\Book1.xlsx"
dbms=excel replace out=mydata;
GETNAMES=yes;
RUN;

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16
Please try mixed = yes option

PROC IMPORT DATAFILE="D:\Book1.xlsx"
dbms=excel replace out=mydata;
GETNAMES=yes;
MIXED=yes;
RUN;
Thanks,
Jag
scb
Obsidian | Level 7 scb
Obsidian | Level 7

I have tried but still got the same answer.

Kurt_Bremser
Super User

Export to a csv file from Excel and write a data step to read that; that way you have full control over the variables and are not subject to the idiosyncrasies of the Excel file format and the guessing of proc import.

Ksharp
Super User

Add MIXED='yes' ;  option

Or not sure if the following could work.

libname xx excel "/folders/myfolders/Book1.xlsx";
data have;
set xx.'Sheet1'n(dbsastype=(holno='char(100)'));
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
  • 4 replies
  • 2234 views
  • 1 like
  • 4 in conversation