Tuesday, March 13, 2012

User Defined Error & Messages to SAS log

/*throw error when excel input contains duplicate values*/
proc sort data = excel_read_in out = dedup
dupout = dups nodupkey;
by str_i fcst_acct_yr_i fcst_acct_mo_i fcst_acct_mo_wk_i;
run;

proc sql noprint;
select count (*) into : nobs_err1 from dups;
run;
%put &nobs_err1;


DATA _NULL_;
%IF &nobs_err1 > 0 %THEN %DO;
PUT "ERROR: The excel sheet is loaded with duplicate values. Please have a look at rmtwork.dups dataset and eliminate duplicate values in excel sheet.";
ABORT;
%END;
RUN;

No comments:

Post a Comment