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);
%let dir = C:\Users\....;
Is your server running Windows? Does it have the same files in the same place as your local machine does?
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
@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?
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.