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?

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!

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