I use the proc cport to create transport files in a macro program, and I get the value of the automatic variable macro syserr to verify that the process is done
By doing a test on an excel file which I modified the extension of xlsx to sas7bdat, I have an error message in the log, but the value of syserr automatic macro variable is equal to 0, is it normal ?
In my program I need to check that the proc cport is well applied without error . Is there a solution other than checking the value of the syserr macro variable ?
please find :
bellow, sas program for test
attached , xlsx with sas7bad extention used for test
%let folder1=/*Here put the path of the library */ ;
%let folder2=/*Here put the path of the file */ ;
libname mylib "&folder1.";
filename tranfile "&folder2./xls4cpotest.sas7bdat";
proc cport lib=mylib file=tranfile memtype=data;
select xls4cpotest;
run;
%put syserr=&syserr.;
%put sysmsg=&sysmsg;
Tested it, and found some peculiar behaviour:
proc cport library=libname file=tranfile memtype=data;
select dataset;
run;
would not set syserr or syscc if the dataset is not a SAS dataset file.
But
proc cport data=libname.dataset file=tranfile;
run;
would set both &syscc and &syserr to 1012 with a .xlsx renamed to .sas7bdat.
(all this on AIX with SAS 9.2)
A further successful step would reset &syserr to 0, but &syscc would persist unless manually set.
I guess that a failure in a single select of the proc cport is not recognized as an ERROR (as other exports may happen in the same cport), but when only one dataset is to be converted, the error condition is set.
Changing the errorcheck= system option to strict did not change this behaviour, BTW.
From the &syserr documentation:
You can use the value of SYSERR as a condition to determine further action to take or to decide which parts of a SAS program to execute. SYSERR is used to detect major system errors, such as out of memory or failure of the component system when used in some procedures and DATA steps. SYSERR automatic macro variable is reset at each step boundary. For the return code of a complete job, see SYSCC Automatic Macro Variable.
(Emphasis by me).
So you should use &syscc instead.
thank you for your replay
but the value of SYSCC is also equal to 0
It does not resolve the problem
best regard
Tested it, and found some peculiar behaviour:
proc cport library=libname file=tranfile memtype=data;
select dataset;
run;
would not set syserr or syscc if the dataset is not a SAS dataset file.
But
proc cport data=libname.dataset file=tranfile;
run;
would set both &syscc and &syserr to 1012 with a .xlsx renamed to .sas7bdat.
(all this on AIX with SAS 9.2)
A further successful step would reset &syserr to 0, but &syscc would persist unless manually set.
I guess that a failure in a single select of the proc cport is not recognized as an ERROR (as other exports may happen in the same cport), but when only one dataset is to be converted, the error condition is set.
Changing the errorcheck= system option to strict did not change this behaviour, BTW.
Hi,
Firstly, sorry, but I am not touching an internet file you posted. Now could you clarify what you are doing. Do you mean to say that you have renamed and Excel file to sas7bdat? That doesn't make any sense, XLSX is Open Office file format, SAS has its own proprietary file format, of course your process is not going to work if you just change the file extension, the file types are very different?
As for checking if proc cport has worked correctly, the error varibles will only tell you if there are errors/warnings. It may be that your data becomes corrupted etc. Personally I would always send along a proc contents before the packing procedure, so the recipient can compare what they get out at the end. That and also having MD5's and such like to check integrity. For your purposes, log checking your logs after - which you will be doing on all your programming and runs - will pull out any problems with the code execution.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.