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

I everyone, im triying to make this code work on server, but it shows me the next error:

 

WARNING: Argument 1 to function DNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set
to a missing value.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
&dnum
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro READ_FILES will stop executing.
89

 

Nevertheless, if i run the same code but with local, i dont get any error, everything works fine. Any clues? Many thanks!

 

BTW This is the code i'm using:

 

 

%let dir = C:\Users\....;
libname INSUMOS "/SASDATA/...../";
%let libreria=INSUMOS.;
options compress=yes;



%macro read_files (dir, LIBRERIA);
%let rc=%sysfunc(filename(rawdata,&dir));
%let did=%sysfunc(dopen(&rawdata));

%let dnum=%sysfunc(dnum(&did));

%do i=1 %to &dnum;
%let name_file=%sysfunc(dread(&did,&i));

%let FORMATO=%sysfunc(scan(&name_file,2,.));

%if &FORMATO=xlsx %then %do;
%let name_file_short=%sysfunc(scan(&name_file,1,.));

data _NULL_; *Extrae el nombre del archivo;
FECHA=scan("&name_file_short",-1,"_");
call symput('FECHA', FECHA);
run;


PROC IMPORT OUT=&LIBRERIA.&name_file_short /
DATAFILE="&dir\&name_file"
DBMS=xlsx
REPLACE;
run;

Data &libreria&name_file_short;
SET &libreria&name_file_short;
FECHA_NOMBRE= "&name_file_short";
FECHA2="&FECHA";
FECHA=input(FECHA2,DDMMYY8.);
FORMAT FECHA DATE9.;
DROP FECHA2;
if RFC = " " then delete;
RUN;

%end;

%end;
data INSUMOS.tot_comb;
set &LIBRERIA.EC:;
run;

%mend;
%read_files(&dir, &libreria);

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
The Server can't see your desktop. You need to either set up a shared location that both the server and your computer can access for file transfers or use the Transfer Data Task to upload/download files. Unfortunately that cannot be scripted.

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User
%let dir = C:\Users\....;

Is your server running Windows?  Does it have the same files in the same place as your local machine does?

Mxmaverick
Calcite | Level 5

Not windows on server. 

 

UPDATE:

 

i tried changing everything to just run on server and it works properly

 

%let dir = /SASDATA/Proyectos/siavo3/prompts/Prueba/;
libname INSUMOS "/SASDATA/Proyectos/siavo3/prompts";

 

but it's not what i want, and at least we know it's not the code

Tom
Super User Tom
Super User

@Mxmaverick wrote:

Not windows on server. 

 

UPDATE:

 

i tried changing everything to just run on server and it works properly

 

%let dir = /SASDATA/Proyectos/siavo3/prompts/Prueba/;
libname INSUMOS "/SASDATA/Proyectos/siavo3/prompts";

 

but it's not what i want, and at least we know it's not the code


Don't leave us hanging like that. Explain what it is that you do want?

Do you want the server to connect to your machine and find the files?  Is your machine running an FTP or SFTP server that it could use?

Mxmaverick
Calcite | Level 5

I want the server to connect to my machine and find the files. Im using SAS GUIDE, so i just need to put an IP, port, user and password. 

Reeza
Super User
The Server can't see your desktop. You need to either set up a shared location that both the server and your computer can access for file transfers or use the Transfer Data Task to upload/download files. Unfortunately that cannot be scripted.
Mxmaverick
Calcite | Level 5
Seems legit, thank you very much.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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