We will only list some basic guidelines here, promoting readability, comprehension and appearance.
Btw. also check out sasjs/lint.
-
Code should not produce Errors, Warnings or Concerning Notes in SAS log
-
Indent using spaces instead of tabs
-
Be consistent with indentation increments
-
Indent conditional blocks and DO groups, and do it consistently, the logic will be easier to follow
-
Avoid mixing symbol and mnemonic versions of comparison operators and use one style consistently
-
End DATA-steps and PROC-steps with a RUN statement. End interactive procedures such as proc sql and proc datasets with a QUIT statement.
-
Group non-executable statements (length, attrib, retain, format, informat, etc.) at the top of a data step before executable statements
-
Two level data set names should always be used, which includes specifying WORK library
-
When available, use string functions that support UTF-8 data. For example, use kfind(...) rather than find(...).
See Internationalization Compatibility for SAS String Functions for more details -
When changing SAS option settings, return the setting to the original value after you are done with them. An example is shown below:
%local etls_syntaxcheck; %let etls_syntaxcheck = %sysfunc(getoption(syntaxcheck)); /* Turn off syntaxcheck option to perform following steps*/ options nosyntaxcheck; %local etls_obs; %let etls_obs = %sysfunc(getoption(obs)); /* Set obs option to max to perform following steps */ options obs = max; /* Code that does the actual work (data processing) goes here */ /* Reset obs option to previous setting */ options obs = &etls_obs; /* Reset syntaxcheck option to previous setting */ options &etls_syntaxcheck;
-
Remove all items created after you are done with them
- Remove all datasets created in work and casuser after you are done with them and they are not part of the output
- Reset all titles, footnotes after you are done with them