SAS Studio

Write and run SAS programs in your web browser
BookmarkSubscribeRSS Feed
potiu
Fluorite | Level 6

Hi,

 

I have a problem on Input statement.

 

Below is the SAS code that I have run.

 

undefined

 

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

 

undefined

 

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.

 

undefined

 

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

 

undefined

 

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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1869 views
  • 0 likes
  • 4 in conversation