Presentation is loading. Please wait.

Presentation is loading. Please wait.

FROM THE TESTING TRENCHES COMMON LOGIC LAPSES AND HOW TO AVOID THEM.

Similar presentations


Presentation on theme: "FROM THE TESTING TRENCHES COMMON LOGIC LAPSES AND HOW TO AVOID THEM."— Presentation transcript:

1 FROM THE TESTING TRENCHES COMMON LOGIC LAPSES AND HOW TO AVOID THEM

2 2 Copyright © 2014, SAS Institute Inc. All rights reserved. DISCLAIMER The views and opinions expressed in the following PowerPoint slides are those of the individual presenter and should not be attributed to the Research Triangle SAS Users Group, or any organization with which the presenter is employed or affiliated. These PowerPoint slides are the intellectual property of the individual presenter and are protected under the copyright laws of the United States of America and other countries. Used by permission. All rights reserved.

3 3 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IS A LOGIC LAPSE? Code runs without error Output looks reasonable Log files look reasonable Off to QA for testing and …

4 4 Copyright © 2014, SAS Institute Inc. All rights reserved. KA-BOOM!

5 5 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date

6 6 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE…

7 7 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX… Apply date format to date variable select IssueDate format=DATE9. as Issue_Date Create DATETIME variable and apply DATETIME format select dhms(IssueDate,0,0,0) format=DATETIME23. as Issue_DTTM

8 8 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats

9 9 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE…

10 10 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX…

11 11 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly

12 12 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE…

13 13 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX…

14 14 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity

15 15 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE… 9 proc sql; 10 create table Case_Example_1 as 11 select City,County,State,ZIP 12 from Case_Example 13 where city="RALEIGH"; NOTE: Table WORK.CASE_EXAMPLE_1 created, with 0 rows and 4 columns. 13 ! quit;

16 16 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX… 15 proc sql; 16 create table Case_Example_2 as 17 select City,County,State,ZIP 18 from Case_Example 19 where upcase(city)="RALEIGH"; NOTE: Table WORK.CASE_EXAMPLE_2 created, with 44 rows and 4 columns. 19 ! quit;

17 17 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks

18 18 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE… 15 proc sql; 16 create table Example_1 as 17 select distinct a.ncgeneralstatute || ' - ' ||b.ncgeneralstatutedescription as NCGS_CAT 18 from extract.sor_offense as a 19 left join extract.sor_refncstatute as b 20 on a.ncgeneralstatute=b.ncgeneralstatute 21 ;

19 19 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX… 23 proc sql; 24 create table Example_2 as 25 select distinct catx(' - ', a.ncgeneralstatute,b.ncgeneralstatutedescription) as NCGS_CATX 26 from extract.sor_offense as a 27 left join extract.sor_refncstatute as b 28 on a.ncgeneralstatute=b.ncgeneralstatute 29 ;

20 20 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks Not accounting for hex characters

21 21 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE… 31 proc sql; 32 create table Hex_Example_1 as 33 select * 34 from Hex_Example 35 where upcase(city)="RALEIGH"; NOTE: Table WORK.HEX_EXAMPLE_1 created, with 0 rows and 5 columns. 35 ! quit;

22 22 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX… 37 proc sql; 38 create table Hex_Example_2 as 39 select * 40 from Hex_Example 41 where upcase(compress(city,,'ak'))="RALEIGH"; NOTE: Table WORK.HEX_EXAMPLE_2 created, with 44 rows and 5 columns. 41 ! quit;

23 23 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks Not accounting for hex characters Incorrect handling of endpoints

24 24 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE… Greater than versus Greater than or equal to Less than versus Less than or equal to Less than versus Greater than LE versus GE Displaying age

25 25 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX… Query test data for cases where date falls inside or outside test range where date matches endpoints where birthday matches test date where date is missing

26 26 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks Not accounting for hex characters Incorrect handling of endpoints Incorrect sorting (primary/secondary/tertiary)

27 27 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE…

28 28 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks Not accounting for hex characters Incorrect handling of endpoints Incorrect sorting (primary/secondary/tertiary) Losing data when converting text strings to SAS dates

29 29 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE… All digits, but invalid date (leap day in non-leap years) 19870229 Missing digits and/or spaces 194 0116 Unexpected characters 20??0704 0101 &A Nonexistent dates 19821169

30 30 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX…

31 31 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSES Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks Not accounting for hex characters Incorrect handling of endpoints Incorrect sorting (primary/secondary/tertiary) Losing data when converting text strings to SAS dates Not imposing integrity constraints on input parameters

32 32 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE…

33 33 Copyright © 2014, SAS Institute Inc. All rights reserved. WHAT IT LOOKS LIKE… yearpredsucc 2023AB posaccountyearexcessfy_1fy_2fy_3 succB2020$0.00$0 succB2021$0.00$0 succB2022$0.00$0 succB2023$0.00$0 predA2020$0.00$0 predA2021$0.00$0 predA2022$0.00$0 predA2023$0.00$0

34 34 Copyright © 2014, SAS Institute Inc. All rights reserved. HOW TO FIX…

35 35 Copyright © 2014, SAS Institute Inc. All rights reserved. LOGIC LAPSE SUMMARY Applying a DATETIME format to a SAS date Not checking for undefined formats Parsing incorrectly Not accounting for case sensitivity Not accounting for leading or trailing blanks Not accounting for hex characters Incorrect handling of endpoints Incorrect sorting (primary/secondary/tertiary) Losing data when converting text strings to SAS dates Not imposing integrity constraints on input parameters

36 36 Copyright © 2014, SAS Institute Inc. All rights reserved. ACKNOWLEDGMENTS Thanks to the developers whose defects made this presentation possible.

37 FOR ADDITIONAL INFORMATION, CONTACT: Jenni M. Elion Senior Development Tester ▪ SAS Solutions OnDemand Tel: + 1 919 531 2642 ▪ Jenni.Elion@sas.com 100 SAS Campus Drive ▪ Cary, NC 27513-2414 USA


Download ppt "FROM THE TESTING TRENCHES COMMON LOGIC LAPSES AND HOW TO AVOID THEM."

Similar presentations


Ads by Google