BookmarkSubscribeRSS Feed
potiu
Fluorite | Level 6

Hi,

 

I have a problem on Input statement.

 

Below is the SAS code that I have run.

 

1.png

 

The result of the show in the log file is as follow:

 

2.png

 

Can I know where did I write wrongly for the code?

 

Thank you.

4 REPLIES 4
art297
Opal | Level 21

Where is the file stored and does it have an extension that you didn't include in specifying it?

 

Art, CEO, AnalystFinder.com

 

Reeza
Super User

@potiu wrote:

Hi,

 

I have a problem on Input statement.

 

Below is the SAS code that I have run.

 

1.png

 

The result of the show in the log file is as follow:

 

2.png

 

Can I know where did I write wrongly for the code?

 

Thank you.


I thought you had an Excel file? If so you should use PROC IMPORT not a data step. There's no definition of the file path in the code shown. Also, post these as text not as images.

Cynthia_sas
SAS Super FREQ

Hi:

  It appears that you are using SAS Studio. If you are reading a CSV comma-separated value file that you have stored in your shared folder location (/folders/myfolders) then I would expect to see an INFILE statement like this:

data work.cervicalcancer;
INFILE '/folders/myfolders/cervicalcancer.csv' dlm=',' dsd;
input var1 var2 var3 var4;
run;

proc print data=work.cervicalcancer;
run;

or, if you are using SAS Studio with SAS OnDemand for Academics, then your INFILE statement might be something like this:

INFILE '/home/your_userid/mydata/cervicalcancer.csv' dlm=',' dsd;

but then the rest of the program would be the same. (as an example for CSV).

 

  If you are reading an Excel file, then you might try the XLSX LIBNAME engine, but in that case, your syntax would be different:

 

libname mysheet xlsx '/folders/myfolders/cervicalcancer.xlsx';

data work.cervicalcancer;
  set mysheet.sheet1;
run;

proc contents data=work.cervicalcancer;
run;

proc print data=work.cervicalcancer;
run;

And, again, if you are using SAS Studio with SAS OnDemand for Academics, then you need to upload your file to the SAS OnDemand server and change only your LIBNAME statement:

 

 

libname mysheet xlsx '/home/your_userid/mydata/cervicalcancer.xlsx';

 

And then, you might also have to change the sheetname if you've named the sheet something other than SHEET1.

 

cynthia

 

Our free Programming 1 e-learning class has information on using the INFILE statement to read a CSV file and there are quite a few previous postings here in the Forum for using the XLSX Libname Engine to read Excel files such as a .XLSX file.

 

  I hope this helps explain that the technique you use to read the input file and the form of your INFILE and/or LIBNAME statement will depend on the type of file you are reading in (CSV vs XLSX).

 

cynthia

 

potiu
Fluorite | Level 6
Thanks Reeza, Cynthia and art297 for the help.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1214 views
  • 0 likes
  • 4 in conversation