Hi,
I have a problem on Input statement.
Below is the SAS code that I have run.
The result of the show in the log file is as follow:
Can I know where did I write wrongly for the code?
Thank you.
Where is the file stored and does it have an extension that you didn't include in specifying it?
Art, CEO, AnalystFinder.com
@potiu wrote:
Hi,
I have a problem on Input statement.
Below is the SAS code that I have run.
The result of the show in the log file is as follow:
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.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.