Hi I am changing the names of sasdata sets in a sas macro. When the new dataset name already exists the program writes an error message to my log. Which is correct. However I am trying to catch this error within the program using the &SYSERR variable. But this is always 0 after the change statment has been executed. Does running the change statment from within a macro effect the value of the &SYSERR variable. Is there another variable that I could use as this would be very handy for error checking. Code is below. %macro ChangeFileName; /* Change the file name of the existing files. The new file name is built using Shared Datasets.File_Names.Archive_File_Name and the postfix returned by the %SetMMYY macro */ %PUT "------- Change File Names------"; %DO i=1 %TO &Bkup_NumObs; %LET FileName = %SYSFUNC(CAT(&Bkup_File_Name,&i)); %LET FileNameMMYY = %SYSFUNC(CAT(&Bkup_File_Name_MMYY,&i)); %LET FileNameMMYY = &FileNameMMYY.&MMYY; %LET Nm = %SYSFUNC(CAT(&DataLibrary,.,&FileName)); %PUT &Nm; %IF %SYSFUNC(exist(%UPCASE(&Nm))) %THEN %DO; %PUT Change &FileName to &FileNameMMYY; CHANGE &FileName= &FileNameMMYY; %PUT &syserr; %END; %ELSE %DO; %PUT ******* &DataLibrary.&FileName does not exists. *******; %END; %END; run; %mend ChangeFileName;
... View more