Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much...

26
1 Programming is Done By Human Beings Ray McKinnis

Transcript of Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much...

Page 1: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

1

Programming is Done By Human Beings

Ray McKinnis

Page 2: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Computer Language And

Human Being Language

Page 3: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Computer Language and Human Being Language

SAS Understands Both

Page 4: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Some Basic Principles Incorporated into SAS

1. Simple and self-documenting. That means understandable to human beings.

2. Let computer do what it does best and humans do best what they do best.

3. Errors that the computer doesn’t understand-explained in language that a human being can understand.

4. And continue scanning code (with obs=0) to see if there are any other mistakes.

5. Everything a human being needs to know to understand the logic and purpose of the file is in the file itself.

Page 5: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Self-Documenting

libname sdtm‘\\server124\fileabc\sdtm’;

data ae1;set sdtm.adae;

keep usubjid aeterm aecodaesae;run;

Page 6: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Good Computer Language Missing Human Language

%includit;

data ae1;set sdtm.adae;

keep usubjid aetermaecod aesae;run

Page 7: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

%includeit;libname sdtm‘\\server124\fileabc\sdtm’;

data ae1;set sdtm.adae;

keep usubjid aeterm aecod aesae;run;

Good Computer LanguageGood Human Language

Page 8: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

WHY Would Anyone Do This?This can get you into trouble.

*Get Data;proc sort data=sdtm.lb out=lb;run;

*Create dataset;data lb1;

set lb;run;

Page 9: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Brilliant SAS Code Speaking Human

Language

if inae and inadsl;

Page 10: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

What Happened? The Human Language has Disappeared

This is MeaninglessTo a Human Being

if a and b;

Not only is this meaningless to a human being, its meaning changes throughout the program.

Page 11: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

data ae;

Good Computer Language

and Human Language

Page 12: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Data data1;orData &data1;

Computer LanguageONLY

Page 13: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Title1 ‘Listing 14.3.10’;Title2 ‘Laboratory Results from the First Two Periods’;Title3 ‘By Gender and Age’;

proc print data=lab;var usubjid partam sex lbresult;

run;

Brilliant SAS FeatureSelf-Documenting at its

BEST

Page 14: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Human Language is Absentand So is Understanding

%titles;proc print data=lab;var usubjid partam sex lbresult;

run;

Page 15: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

%dates(indate=,outdate=);

*Human beings need some help in understanding this;

Page 16: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

%dates(indate=,outdate=);

*Macro for converting a date from ddMONyyyy into dd Month yyyy format;

Page 17: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

%dates(indate=,outdate=, type=, source=, missing=, use=, format=, error=, level=);

*Macro for converting a date from ddMONyyyy into dd Month yyyy format; And too much more!

Page 18: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

aedur = aeendt – aestdt;

GOOD SAS CODE

Page 19: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

if aeendt>. and aestdt>. then aedur = aeendt – aestdt;

CONFUSING SAS CODEWhy Do This?

Page 20: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

trtn = 1*trtc;

GOOD, CLEAR, CLEAN SAS CODE

Page 21: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

trtn = input(trtc,best.)

SO WHY MAKE IT CONFUSINGLike This?

Page 22: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

PROC PRINTPROC SORTPROC MEANSPROC FREQPROC UNIVARIATEPROC SQL?

Which of These is Self Documenting?

Page 23: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

SQL CODE

proc sql;create table case2 as select a.*, b.visitnumas numfrom case1(where=(visitnum=.)) as aleft joinsv as bon a.usubjid=b.usubjid and substr(a.&date.,1,10)=b.svstdtc;quit;

Page 24: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

SAS Codedata unsched; set case1; run;

proc sort data=unsched; by usubjid; run;

data sv1; set sv; run;

proc sort data=sv1; by usubjid; run;

data unsched1; merge unsched(in=inunsc) sv1(in=insv);

by usubjid;run;

Page 25: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into making sure the computer will understand it.

Otherwise you are dancing on only one leg. SAS was developed so that you could easily

use both legs: a computer and a human being.

The Point of This Presentation is Simply:

Page 26: Programming is Done By Human Beings - Lex Jansen · Whenever you use SAS programming, put as much effort into making sure that it is understandable by another human being as into

If done simply, I believe it could save hundreds of hours and thousands of dollars in the business of drug development.

The Kicker: