BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6

Hello everyone,

I have a excel file with one column,

I want to import it into SAS and get an character variable,I attached the excel file.

My problem is : if I opended the excel file then run the SAS code, the variable will be like 0.745 for the first obs ,but if I close the excel file then run the SAS code ,the value of the first obs will be changed to 74.5%.

Could anyone help me point out the reason of the problem?

Thanks!

Mike

PROC IMPORT

OUT= _test2

datafile="c:\temp\oops.xls"

DBMS=EXCEL REPLACE;

GETNAMES=YES;

MIXED=YES;

USEDATE=YES;

SCANTIME=YES;

RUN;

3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12

delete the first two blank rows so PROC IMPORT will work as intended.

The data in the spreadsheet are actually numeric with a format applied by Excel.

JRTait
Calcite | Level 5

Mike,

If you do want this variable to be a character variable you can use the following option within your PROC IMPORT:

DBDSOPTS= "DBSASTYPE=(%_of_value='Char(4)')";

When running this you may also want to change the MIXED option from YES to NO.

Ksharp
Super User

Interesting , If you use another engine XLS ,you will different result:

PROC IMPORT

OUT= _test2

datafile="c:\temp\oops.xls"

DBMS=xls REPLACE;

GETNAMES=YES;

MIXED=YES;

RUN;

Ksharp

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 907 views
  • 3 likes
  • 4 in conversation