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


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;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

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.

reznac
Obsidian | Level 7

thank you for your replay 

but the value of SYSCC  is also equal to 0 

It does not resolve the problem 

 

best regard 

Kurt_Bremser
Super User

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.

reznac
Obsidian | Level 7
thank you for the solution
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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