1         Data maintenance

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.

 

 

1.1       Audit data changes

 

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

 

DATA                         libname.SASfilename;

            SET                libname.SASfilename;

 

****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.*/

 

                        Varname2=new value;

                        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.

End;

 

·         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;

AUDIT                       SASfilename;

                        INITIATE;

                        RUN;

QUIT;

 

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.;

RUN;

 

1.2       Calculate SAS running time to second

 

%LET start=%str(%sysfunc(date(),yymmdds10.) %sysfunc(time(),time8.));

 

/*program to run here*/

OPTIONS CLEANUP  ;

%LET end=%str(%sysfunc(date(),yymmdds10.) %sysfunc(time(),time8.));

 

 

DATA TIME;

FORMAT start $30. end $30. ;

start="&start";

end="&end";

RUN; /* you will see the start time and end time in the data time*/