BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
elmendamian
Fluorite | Level 6

Hello everyone.
I am trying to call a .sas program in SAS Viya from a location on the server.
I have used the filesrvc command but it doesn't work.


These are the sentences:

filename myfldr filesrvc folderPath = '/Users/Edachiardi/CodigosSAS /';
data _null_;
infile myfldr ('infile_put.sas');
run

 

This is the log:

NOTE: The infile library MYFLDR is:
Directory = / Users / Edachiardi / CodigosSAS /,
Folder Identifier = af055b98-acdc-44f8-a874-da6bdd394aa4,
Last Modified = November 10, 2019 17H46
NOTE: The infile MYFLDR ('infile_put.sas') is:
Filename = infile_put.sas,
URI path = / files / files / 12f21451-b610-4fb7-b1ed-cbc76791a98b,
File Identifier = 12f21451-b610-4fb7-b1ed-cbc76791a98b,
Content Type = application / octet-stream,
Parent URI = / folders / folders / af055b98-acdc-44f8-a874-da6bdd394aa4,
RECFM = V, LRECL = 32767, File Size (bytes) = 135,
Last Modified = November 10, 2019 18H02,
Create Time = November 10, 2019 4:45 PM
NOTE: A total of 0 records were read from the infile library MYFLDR.
NOTE: 0 records were read from the infile MYFLDR ('infile_put.sas').
NOTE: DATA statement has used (Total process time):
real time 0.52 seconds
cpu time 0.17 seconds

Any ideas for correct invocation.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Multiple questions you need to answer.

Does the file exist? Is it not empty? Does it actually have SAS code? Or something else?

You could make a slight change to your DATA step so you could look at the first few lines of the file.

filename myfldr filesrvc folderPath = '/Users/Edachiardi/CodigosSAS /';
data _null_;
  infile myfldr ('infile_put.sas') obs=5;
  input;
  list;
run;

If it looks like it is there and is the code you want to run then try replacing the DATA step with the %INCLUDE statement.

filename myfldr filesrvc folderPath = '/Users/Edachiardi/CodigosSAS /';
%include myfldr ('infile_put.sas') / source2;

View solution in original post

6 REPLIES 6
elmendamian
Fluorite | Level 6

Hi , thanks for your answer.

The %include statement works in SAS Guide or base, in VIYA doesn't work. The recommendation for "accessing a File by Name and Folder" in SAS VIYA is the "fileserv" instruction.

 

I need to include lot of sas code files into a data step but I could not.

Regards

 

Tom
Super User Tom
Super User

Multiple questions you need to answer.

Does the file exist? Is it not empty? Does it actually have SAS code? Or something else?

You could make a slight change to your DATA step so you could look at the first few lines of the file.

filename myfldr filesrvc folderPath = '/Users/Edachiardi/CodigosSAS /';
data _null_;
  infile myfldr ('infile_put.sas') obs=5;
  input;
  list;
run;

If it looks like it is there and is the code you want to run then try replacing the DATA step with the %INCLUDE statement.

filename myfldr filesrvc folderPath = '/Users/Edachiardi/CodigosSAS /';
%include myfldr ('infile_put.sas') / source2;
elmendamian
Fluorite | Level 6

Hi Tom, thank you very much.

The second sentence that you send me works very good.

This is the log.

1     OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
77    
78    filename myfldr filesrvc folderPath = '/Users/Edachiardi/CodigosSAS/';
79    data file;
80    %include myfldr ('infile_put2.sas') / source2;
NOTE: %INCLUDE (level 1) file MYFLDR(infile_put2.sas) is file infile_put2.sas.
81   +   input x y month $;
82   +   datalines;
NOTE: The data set WORK.FILE has 4 observations and 3 variables.
NOTE: DATA statement ha utilizado (Tiempo de proceso total):
      real time           1.01 seconds
      cpu time            0.25 seconds
      
87   +;
NOTE: %INCLUDE (level 1) ending.
88    run;
89    
90    OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
104   

Regards.

elmendamian
Fluorite | Level 6

Hello again, looks this log

 

1     OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
77    
78    data file;
79    %include "/Users/Edachiardi/CodigosSAS/infile_put2.sas";
WARNING: Physical file does not exist, /Users/Edachiardi/CodigosSAS/infile_put2.sas.
ERROR: Cannot open %INCLUDE file /Users/Edachiardi/CodigosSAS/infile_put2.sas.
80    run;
NOTE: The data set WORK.FILE has 1 observations and 0 variables.
NOTE: DATA statement ha utilizado (Tiempo de proceso total):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
81    
82    
83    OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
97    

 

 

VIYA was installed in a server Linux

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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