It is a quite often situation when we are handling dataset that the original data we still contain some undesired or discrepant values. Here are some tips for handling these kinds of issues.
All the above modifications can be called as hardcoding. Hardcoding is explicitly creating, deleting, or overriding certain variables’ values based on certain criteria. Sometime, you have to do hardcoding several times in the period of your data management. There are several ways to help you monitor and improve your hardcoding process. Here, we introduce two ways:
· Add notes and hardcoding expiring step into your SAS code
****HARDCOE APPROVED BY PEOPLE’S NAME ON DATE;
IF varname1=”name” and “&sysdate” <= “date” then do; /* here, the hardcoding expiring step is added. It will not allow to do the hardcoding after the date you specified here.*/
Put “KeyID_var” varname1 “hardcoded to change” varname2; /* PUT statement will be provided to the SAS log indicating hardcoding has been used in your data management process.
· Audit Trails
Audit trail is a function in SAS which will create an auxiliary data set that keeps track of the data changes made to the subject table.
To initiate the function:
PROC DATASETS LIBRARY=libname;
To show the change you made in your subject table;
PROC PRINT DATA=libname.SASfilename (TYPE=AUDIT);
VAR varname _atdatetime_; /* varname is the variable you modified its value in your subject table*/
FORMAT _atdatetime_ tod.;
%LET start=%str(%sysfunc(date(),yymmdds10.) %sysfunc(time(),time8.));
/*program to run here*/
OPTIONS CLEANUP ;
%LET end=%str(%sysfunc(date(),yymmdds10.) %sysfunc(time(),time8.));
FORMAT start $30. end $30. ;
RUN; /* you will see the start time and end time in the data time*/