/* * Copyright © 2009 SAS Institute Inc., * SAS 9.2 EBIAPM92 sample artifactusagedetails elapsedTime column update utility * * ebiapm_update_artifactusagedetails.sas * * update the elapsedtime value in the data set for instances where the time values * are incorrectly processed as negative values. Values less than zero will be set to zero * and resulting values elapsedtime recalculated. */ /* UPDATE THE LIBNAME and WORKLIB as desired */ /* Specificy the libname location to artifactsusagedetails data set*/ libname artifact 'c:\sas92\ebiapm92\data\artifacts'; %let WORKLIB=work.artifactusagedetails; /* create a work.artifactusagedetails table to validate the changes behave as expected */ %macro artifact_work; PROC SQL; CREATE TABLE &WORKLIB. AS SELECT * FROM artifact.artifactusagedetails AS t1 WHERE sourceid contains 'WorkspaceServer' and t1.elapsedTime < 0 AND t1.elapsedTime NOT IS MISSING ORDER BY t1.elapsedTime; QUIT; proc sql; UPDATE &WORKLIB. SET elapsedSystemCPUTime=0 WHERE (elapsedSystemCPUTime < 0 and elapsedSystemCPUtime ne . ); quit; proc sql; UPDATE &WORKLIB. SET elapsedUserCPUTime=0 WHERE (elapsedUserCPUTime < 0 and elapseduserCPUTime ne . ); quit; proc sql; UPDATE &WORKLIB. SET elapsedTotalCPUTime=ElapsedUserCPUtime + ElapsedSystemCPUTime WHERE ( elapsedTotalCPUTime < 0 and elapsedTotalCPUtime ne . ); quit; proc sql; UPDATE &WORKLIB. SET elapsedTime=elapsedTotalCPUTime WHERE ( elapsedTime < 0 and elapsedtime ne . ); quit; %mend artifact_work; %macro artifact_update; /* create a generic backup of the artifactusagedetails data set before processing */ proc sql; create table artifact.artifactusagedetails_backup as select * from artifact.artifactusagedetails a; quit; proc sql; UPDATE artifact.artifactusagedetails SET elapsedSystemCPUTime=0 WHERE ( sourceid contains 'WorkspaceServer' and elapsedSystemCPUTime < 0 and elapsedSystemCPUtime ne .); quit; proc sql; UPDATE artifact.artifactusagedetails SET elapsedUserCPUTime=0 WHERE ( sourceid contains 'WorkspaceServer' and elapsedUserCPUTime < 0 and elapseduserCPUTime ne . ); quit; proc sql; UPDATE artifact.artifactusagedetails SET elapsedTotalCPUTime=ElapsedUserCPUtime + ElapsedSystemCPUTime WHERE ( sourceid contains 'WorkspaceServer' and elapsedTotalCPUTime < 0 and elapsedTotalCPUtime ne . ); quit; proc sql; UPDATE artifact.artifactusagedetails SET elapsedTime=elapsedTotalCPUTime WHERE (sourceid contains 'WorkspaceServer' and elapsedTime < 0 and elapsedtime ne . ); quit; %mend artifact_update; %artifact_work; /* * Uncomment the following macro defintion to execute the actual update to artifact.artifactusagedetails * * NOTE: A backup is created as well, artifact.artifactusage_backup * */ /* %artifact_update; */