DATA Step, Macro, Functions and more

proc cport and syserr

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

proc cport and syserr


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;
Attachment

Accepted Solutions
Solution
‎12-19-2016 10:23 AM
Super User
Posts: 6,972

Re: proc cport and syserr

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 6,972

Re: proc cport and syserr

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 19

Re: proc cport and syserr

thank you for your replay 

but the value of SYSCC  is also equal to 0 

It does not resolve the problem 

 

best regard 

Solution
‎12-19-2016 10:23 AM
Super User
Posts: 6,972

Re: proc cport and syserr

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 19

Re: proc cport and syserr

thank you for the solution
Super User
Super User
Posts: 7,430

Re: proc cport and syserr

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 219 views
  • 0 likes
  • 3 in conversation