SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Karem
Fluorite | Level 6

Hi.

 

I'm having  trouble in importing XLS file to SAS data set. Proc Import works, but the SAS data set produces all observation as CHAR.

 

I checked the XLS file (which is software generated file), and i have found that all observation has an APOSTROPHE ( ' ), whether it is

CHAR or NUM header. While (1st Row) Header do not have this apostrophe ( ' ).

 

How can i removed this apostrophe ( ' ), so that SAS can translate correct observation type in all header ?

 

Note: Find/Replace in Excel can't find apostrophe ( ' )

 

XLS Numeric Header: With ( ' )

undefined

 

XLS Char Header: With ( ' )

undefined

 

XLS (First Row) Header: Without ( ' )

undefined

 

 

CODE:

proc import out= name

datafile= "&fpath"

dbms=xls replace;

getnames=yes;

datarow=2;

mixed=no;

run;

 

 

thanks!

 

Karem

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Another good example of why Excel is a really poor data medium, these "helpful" Excel bits.  I would suggest you save the file into CSV and then write a datastep to import the data into the model you know - i.e.

data want;
  infile "mydata.csv";
  input status $ x y;
run;

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Another good example of why Excel is a really poor data medium, these "helpful" Excel bits.  I would suggest you save the file into CSV and then write a datastep to import the data into the model you know - i.e.

data want;
  infile "mydata.csv";
  input status $ x y;
run;
Kurt_Bremser
Super User
data name_new (rename=(
  status=_status
  x = _x
  y = _y
));
set name;
status = substr(_status,2);
x = input(substr(_x,2),best.);
y = input(substr(_y,2),best.);
drop _status _x _y;
run;

after the import.

Or get rid of the crappy xls format, as @RW9 suggested.

Karem
Fluorite | Level 6

 

 

Thank you! @KurtBremser / @RW9.

 

Converting to csv is simpler considering if there will be a numerous header.

 

 

 

best regards,

 

Geof

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2917 views
  • 1 like
  • 3 in conversation