Skip to content
Prev 171899 / 398503 Next

Inefficiency of SAS Programming

2009/2/26 Frank E Harrell Jr <f.harrell at vanderbilt.edu>:
Plenty of examples ripe for sending to www.thedailywtf.com there. Like this:

    IF &N. =  1 THEN SUB_N = 1;
    IF &N. =  3 THEN SUB_N = 2;
    IF &N. =  4 THEN SUB_N = 3;
    IF &N. =  6 THEN SUB_N = 4;
    IF &N. =  7 THEN SUB_N = 5;
    IF &N. =  8 THEN SUB_N = 6;
    IF &N. =  9 THEN SUB_N = 7;
    IF &N. = 10 THEN SUB_N = 8;
    IF &N. = 11 THEN SUB_N = 9;
    IF &N. = 12 THEN SUB_N = 10;
    IF &N. = 13 THEN SUB_N = 11;
    IF &N. = 14 THEN SUB_N = 12;
    IF &N. = 15 THEN SUB_N = 13;
    IF &N. = 17 THEN SUB_N = 14;
    IF &N. = 18 THEN SUB_N = 15;
    IF &N. = 19 THEN SUB_N = 16;

Of course it's possible to write code like that in any language, it
just looks worse when it's in ALL CAPS and written in a style that
looks like the 1980s and onward never happened. The question is
whether it's possible to write this better in SAS. Most of us on this
list could write it in R in a better way.

 Barry