Dropping Unnecessary Variables When Building a SAS Data Set from Raw Data
Which is more efficient?
Code 1:
DATA SCORE; ARRAY KEY[5] $ 1; ARRAY Q[5] $ 1; RETAIN KEY1 "A" KEY2 "B" KEY3 "C" KEY4 "D" KEY5 "E"; INPUT (Q1-Q5)($1.); RAW =0; * Added statement by REJ; DO I=1 TO 5; RAW+(Q[I]=KEY[I]); END; PERCENT=100*RAW/5; DATALINES; ABCDA BBCAC EBCAD ;
Code 2:
DATA SCORE; ARRAY KEY[5] $ 1; ARRAY Q[5] $ 1; RETAIN KEY1 "A" KEY2 "B" KEY3 "C" KEY4 "D" KEY5 "E"; INPUT (Q1-Q5)($1.); RAW = 0; * Added statement by REJ; DO I=1 TO 5; RAW+(Q[I]=KEY[I]); END; PERCENT=100*RAW/5; KEEP RAW PERCENT; *or DROP KEY1-KEY5 Q1-Q5 I; DATALINES; ABCDA BBCAC EBCAD ;