Write and run SAS programs in your web browser

Problem on Input Statement

Reply
Occasional Contributor
Posts: 9

Problem on Input Statement

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.

PROC Star
Posts: 7,366

Re: Problem on Input Statement

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

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 17,963

Re: Problem on Input Statement


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.

SAS Super FREQ
Posts: 8,745

Re: Problem on Input Statement

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

 

Occasional Contributor
Posts: 9

Re: Problem on Input Statement

Thanks Reeza, Cynthia and art297 for the help.
Ask a Question
Discussion stats
  • 4 replies
  • 138 views
  • 0 likes
  • 4 in conversation