Divide By Zero Error In Sas
Contents |
Division by Zero Tips and Techniques Manage Division by ZeroA common problem when processing data is the generation of missing values due to a division by zero. sas floating point zero divide SAS will report the occurrence in the log but there is no sas division by zero indication of the cause in the data itself. NOTE: Division by zero detected at line 18 column 26. numerator=150 denominator=0 division by zero detected in sas calc_result=. func_result=I _ERROR_=1 _N_=2 NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 18:26
Sas Divide Function
A report listing the data will simply show that the values are missing. This situation can be far better managed by using the divide function to perform the calculation. data create_data; input numerator denominator; cards; 150 1 150 0 150 . run; data divide_function; set create_data; calc_result=numerator/denominator; func_result=divide(numerator,denominator); run; Now when using the divide function in place of a calculation a division by zero results divide by zero sas in the special missing value of 'I' which represents a result of infinity. A simple reporting procedure will display this value in the output. title 'Using the data for a listing'; proc print data=divide_function; run; Proc Print produces the following listing, note the 'I' in the output Using the data for a listing calc_ func_ Obs numerator denominator result result 1 150 1 150 150 2 150 0 . I 3 150 . . . However when we use the same data to generate a calculated value it is treated as any other missing value would be, for example Proc Means. title 'Using the data to calculate statistics'; proc means data=divide_function mean n; var calc_result func_result; run; The Proc Means procedure ignores missing values. Below we can see that only one record has been used in the calculation and the 'I' value has been ignored along with the other missing values. Using the data to calculate statistics The MEANS Procedure Variable Mean N calc_result 150.0000000 1 func_result 150.0000000 1« Back to SAS Data Management« Back to all Tips and Techniques SAS TrainingCourse List & Book SAS TrainingPublic TrainingOn-Site TrainingOn-Demand TrainingPrices and
Zero" error when using a SAS data file? Please Note! The problem described here only applies to Stat/Transfer Version 7 and earlier. This problem has been remedied in Stat/Transfer Version 8 and above. Say that you used Stat/Transfer to make a SAS data file called c:\mydata\hartman.sas7bdat and you go to use it in a statistics procedure (in our example, proc reg) like below proc reg data="c:\mydata\hartman"; model y = time cond; run; and you get the following error in the log file. NOTE: PROCEDURE REG used: real time 0.00 seconds cpu time 0.00 seconds ERROR: Integer divide by zero. NOTE: The SAS System stopped processing this step because http://www.amadeus.co.uk/sas-training/tips/3/1/46/manage-division-by-zero.php of errors. 20 proc reg data="c:\mydata\hartman"; 21 model y = time|cond; 22 run; 23 What went wrong? Sometimes Stat/Transfer may make a SAS file that SAS has trouble reading in a statistical procedure, but there is a workaround. You can make a copy of the data file in SAS (because SAS can read the file in a data step) and then use the copy. For example, data hartman; set "c:\mydata\hartman"; run; proc reg data=hartman; model http://www.ats.ucla.edu/stat/sas/faq/dividezero.htm y = time cond; run; and then the log file shows that this worked, 72 data hartman; 73 set "c:\mydata\hartman"; 74 run; NOTE: There were 9 observations read from the data set c:\mydata\hartman. NOTE: The data set WORK.HARTMAN has 9 observations and 3 variables. NOTE: DATA statement used: real time 0.00 seconds cpu time 0.00 seconds 75 76 proc reg data=hartman; 77 model y = time cond; 78 run; NOTE: 9 observations read. NOTE: 1 observations have missing values. NOTE: 8 observations used in computations. 79 quit; NOTE: PROCEDURE REG used: real time 0.02 seconds cpu time 0.02 seconds Now everything looks good and you can proceed to analyze the copy of your data file. We wish to thank David Wagstaff of The Methodology Center at Pennsylvania State University for informing us of this error and providing the example data file. How to cite this page Report an error on this page or leave a comment The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California. IDRE Research Technology Group High Performance Computing Statistical Computing GIS and Visualization High Performance Computing GIS Statistical Computing Hoffman2 Cluster Mapshare Classes Hoffman2 Account Application Visualization Conferences Hoffman2 Usage Statistics 3D Modeling Reading Materials UC Grid Portal Technology Sandbox ID
van GoogleInloggenVerborgen veldenZoeken naar groepen of berichten
Applications Campus Information Change Management ConnectCarolina Directory Finance One Card Onyen & Guest ID PID TIM Data Storage AFS Backup and Recovery Connected Backup Data Policies and Usage ITS Enterprise Storage Mass Storage Network Attached Storage (NAS) Secure Network Attached Storage (SecNAS) Educational Technology Course Resources E-Learning Exam Scanning Libraries Sakai Virtual Lab Email Calendar Encryption Exchange HeelMail Introduction to Email LDAP Listserv MassMail Spam and Phishing Webmail Game Systems PS3 PS4 Wii WiiU Xbox 360 Xbox One Mobile Devices Android iOS Windows Networking Advanced Networking Connecting to the Network NAC Network Basics Network Coverage Network Policy WiFi Wireless Networking Office 365 Printing Research Computing Computational GIS Math and Stat Applications SAS Scientific Applications UNIX and Linux Virtual Computing Lab (VCL) Visualization Applications Security Authentication Challenge-Response Questions Data Identification Data Loss Prevention Encryption Endpoint Protection Malware Network-based Onyen and Password Management Policies and Legal Issues Security Best Practice Security Policy Sensitive Information Remediation (SIR) Two-factor authentication User Awareness Virtual Private Network (VPN) Vulnerability Management Software Adobe Adobe Creative Cloud Antivirus Browser Internet Explorer Linux Mac OS X Microsoft Office 365 SAS Sharepoint Software Acquisition Software Center Unix Windows Support CCI FAQ CCI Grant CCI ImageUltra CCI Laptop CCI ThinkCentre Computer Labs Remedy Services Virtual Lab Telecommunications Billing Network-based Voicemail Web Accessibility Carolina CloudApps Web Design and Programming WordPress Mathematical and Statistical Application - SAS - Efficient programming in SAS Table of Contents Introduction Efficiency Computer resources Human resources Additional help Introduction This document is intended for users who have some experience with SAS. It contains a number of examples of SAS code to help you become a better SAS programmer as well as help you better understand of how SAS works. Efficiency We know that efficiency is generally a good thing, but what does "efficiency" mean in talking about SAS programming? When we talk about "efficiency" we mean getting your job done in a way that mi