The correct way of hardcoding

Sometimes even after a good attempt by clinical data management at cleaning and coding the data, you may still find the data contain some undesired values. Therefore, you may need to use hardcoding to override the data before you have time to fix them in data management system.

However, hardcoding is dangerous and it is better to avoid hardcoding in any circumstance. One big reason is that data often change over time and the hardcoding writing today may not be appropriate in the future. A hardcode can be easily forgotten and the left code normally will lead to an unpredictable error when you analyze the data.

If hardcoding must be done, some programming skills may be helpful to reduce that risk. See the example below, the &sysdate was used to force the hardcoding to expire at some date point.

 

data test;
  set test;
  * Hardcode approved by Someone on 12/13/2012;
  if identity = "NEMISIS" and "&sysdate"d <= "13Dec12"d then do;
    ....;
    ....;
  end;
run;

 

 

Posted in SAS Programming Tips and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *