Upload
georgina-skinner
View
218
Download
1
Embed Size (px)
Citation preview
2Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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.
3Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
WHAT IS A LOGIC LAPSE?
• Code runs without error• Output looks reasonable• Log files look reasonable• Off to QA for testing and …
5Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
LOGIC LAPSES
• Applying a DATETIME format to a SAS date
7Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
HOW TO FIX…
• Apply date format to date variableselect IssueDate format=DATE9. as Issue_Date
• Create DATETIME variable and apply DATETIME formatselect dhms(IssueDate,0,0,0) format=DATETIME23. as Issue_DTTM
8Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
LOGIC LAPSES
• Applying a DATETIME format to a SAS date• Not checking for undefined formats
11Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
LOGIC LAPSES
• Applying a DATETIME format to a SAS date• Not checking for undefined formats• Parsing incorrectly
14Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
LOGIC LAPSES
• Applying a DATETIME format to a SAS date• Not checking for undefined formats• Parsing incorrectly• Not accounting for case sensitivity
15Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
WHAT IT LOOKS LIKE…
9 proc sql;10 create table Case_Example_1 as11 select City,County,State,ZIP12 from Case_Example13 where city="RALEIGH";NOTE: Table WORK.CASE_EXAMPLE_1 created, with 0 rows and 4 columns.
13 ! quit;
16Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
HOW TO FIX…
15 proc sql;16 create table Case_Example_2 as17 select City,County,State,ZIP18 from Case_Example19 where upcase(city)="RALEIGH";NOTE: Table WORK.CASE_EXAMPLE_2 created, with 44 rows and 4 columns.
19 ! quit;
17Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
18Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
WHAT IT LOOKS LIKE…
15 proc sql;16 create table Example_1 as17 select distinct a.ncgeneralstatute || ' - ' ||b.ncgeneralstatutedescription as NCGS_CAT18 from extract.sor_offense as a19 left join extract.sor_refncstatute as b20 on a.ncgeneralstatute=b.ncgeneralstatute21 ;
19Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
HOW TO FIX…
23 proc sql;24 create table Example_2 as25 select distinct catx(' - ', a.ncgeneralstatute,b.ncgeneralstatutedescription) as NCGS_CATX26 from extract.sor_offense as a27 left join extract.sor_refncstatute as b28 on a.ncgeneralstatute=b.ncgeneralstatute29 ;
20Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
21Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
WHAT IT LOOKS LIKE…
31 proc sql;32 create table Hex_Example_1 as33 select *34 from Hex_Example35 where upcase(city)="RALEIGH";NOTE: Table WORK.HEX_EXAMPLE_1 created, with 0 rows and 5 columns.
35 ! quit;
22Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
HOW TO FIX…
37 proc sql;38 create table Hex_Example_2 as39 select *40 from Hex_Example41 where upcase(compress(city,,'ak'))="RALEIGH";NOTE: Table WORK.HEX_EXAMPLE_2 created, with 44 rows and 5 columns.
41 ! quit;
23Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
24Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
25Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
26Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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)
28Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
29Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
31Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
33Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
WHAT IT LOOKS LIKE…
year pred succ 2023 A B
pos account year excess fy_1 fy_2 fy_3succ B 2020 $0.00 $0 $0 $0 succ B 2021 $0.00 $0 $0 $0 succ B 2022 $0.00 $0 $0 $0 succ B 2023 $0.00 $0 $0 $0 pred A 2020 $0.00 $0 $0 $0 pred A 2021 $0.00 $0 $0 $0 pred A 2022 $0.00 $0 $0 $0 pred A 2023 $0.00 $0 $0 $0
35Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights 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
36Copy r ight © 2014, SAS Ins t i tu te Inc . A l l r ights reserved.
ACKNOWLEDGMENTS
Thanks to the developers whose defects
made this presentation possible.
FOR ADDITIONAL INFORMATION, CONTACT:
Jenni M. Elion
Senior Development Tester ▪ SAS Solutions OnDemand
Tel: + 1 919 531 2642 ▪ [email protected]
100 SAS Campus Drive ▪ Cary, NC 27513-2414 USA