BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jc3992
Pyrite | Level 9

Hello everyone,

 

[Updated]

Thank you very much for all your helps.

after saving to CSV file. It worked.

Thank you very much

 

proc import datafile="&dirdata.umaru.csv" out=umaru dbms=csv
replace;
delimiter=',';
getnames=yes;
run;

proc print data=umaru;
run;

 

 

I have been a while not use SAS but I am not so sure of this.

The data is like this:

The biggest column for "id" is 3 integers

for variable "back" the biggest space is 6.

 

What I used was:

Data umaru;
  INFILE "&dirdata.umaru.xlsx" dlm="," dsd;
  INPUT id 1-3 age  beck 7. ivhx 14-15  ndrugtx 16-17  race 18-19 treat 20-21 site 22-23  dfree 24-25;
  run;

Thank you very much!

A appreciated all the advice. Thanks!

 

id	age	beck	ivhx	ndrugtx	race	treat	site	dfree
1	39	9	3	1	0	1	0	0
2	33	34	2	8	0	1	0	0
3	33	10	3	3	0	1	0	0

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19
Excel files can't be read with indole & input. You need either proc import or a libname statement.
If your file just ends with xlsx but is a normal text-file (you can open it with notepad) then reading it with infile & input is possible. You should just look up the input statement in the docs. Hint: specify start and end for each variable as you did for id.

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19
Excel files can't be read with indole & input. You need either proc import or a libname statement.
If your file just ends with xlsx but is a normal text-file (you can open it with notepad) then reading it with infile & input is possible. You should just look up the input statement in the docs. Hint: specify start and end for each variable as you did for id.
ballardw
Super User

Or save the XLSX as CSV and use a delimited input.

It is hard to get fixed column text out of Excel but easy to get delimited: go to file>Save As> select CSV

Reeza
Super User
XLSX files are not fixed space data, it's data stored in a proprietary format. Have you tried using PROC IMPORT?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1324 views
  • 3 likes
  • 4 in conversation