DATA Step, Macro, Functions and more

&syserr macro not working in PROC DATASETS

Reply
Contributor
Posts: 41

&syserr macro not working in PROC DATASETS

Hi I'm using Proc datasets moving option to moving data from one library to another if datasets not available I need to capture Warning/error from code. Same&syserr macro working in data step but not working in proc datasets. pls advise me how to capture error.

/*1-WORKING*/

data NULL;

set doesnotexist;

run;

%put &syserr;

/*2-NOT WORKING*/

PROC DATASETS;

COPY IN=Source OUT=Target MOVE MEMTYPE=DATA;

RUN;

%put &syserr;

Contributor
Posts: 67

Re: &syserr macro not working in PROC DATASETS

Posted in reply to chirumalla

Hi Chirumalla,

PROC DATASETS is part of run group processing, which means that the step doesn't actually finish until it encounters a QUIT statement or the start of a new step. A plain old run statement just executes your COPY statement but does not terminate PROC DATASETS and SYSERR only gets updated correctly when the step has terminated. Simply add a quit statement before checking the value of SYSERR. 

 

/*1-WORKING*/
data NULL;
set doesnotexist;
run;
%put error is &syserr;
/*2-ALSO WORKING*/
PROC DATASETS;
COPY IN=Source OUT=Target MOVE MEMTYPE=DATA;
RUN;
quit;
%put error is &syserr;

Michelle
New Contributor
Posts: 4

Re: &syserr macro not working in PROC DATASETS

Posted in reply to mbuchecker

Hello Michel,

 

Thanks... It worked for me by doing suggested changes.

 

 

 

Manoj

Ask a Question
Discussion stats
  • 2 replies
  • 259 views
  • 1 like
  • 3 in conversation