Division 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 will report the occurrence in the division by zero detected in sas log but there is no indication of the cause in the data itself. NOTE: Division
Sas Divide By Zero
by zero detected at line 18 column 26. numerator=150 denominator=0 calc_result=. func_result=I _ERROR_=1 _N_=2 NOTE: Missing values were generated as a result sas divide function of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 18:26 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 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 DiscountsTestimonials & Case StudiesFree ResourcesTips and TechniquesTechnical Papers Print this page Back to top Address Mulberry House 9 Church Green Witney Oxfordshire OX28 4AZ UK Phone +44(0)1993848010 Email us Latest News Thank You For Visiting Our Stand - SAS Forum UKLive On-Stand Demonstrations at the SAS UK For
turn on suggestions Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. Showing results for Search instead for Do you mean Find a Community Communities Welcome Getting Started Community Memo Community Matters Community Suggestion Box Have Your Say SAS Programming Base SAS Programming SAS Procedures ODS and Base Reporting SAS/GRAPH and ODS Graphics General SAS Programming SAS Studio Data Management SAS Data Management Analytics SAS Statistical Procedures SAS/IML Software and Matrix Computations SAS Data Mining SAS Text and Content Analytics SAS Forecasting and Econometrics Mathematical Optimization, Discrete-Event Simulation, and OR Business Intelligence SAS Enterprise Guide Integration with Microsoft Office SAS http://www.amadeus.co.uk/sas-training/tips/3/1/46/manage-division-by-zero.php Visual Analytics SAS Web Report Studio SAS Stored Processes Administration Administration and Deployment SAS Hot Fix Announcements SAS ITRM Learn SAS SAS Analytics U SAS Certification Customer Intelligence SAS Customer Intelligence SAS Intelligent Advertising Risk Management SAS Risk Management SAS Viya About SAS Viya SAS Visual Data Mining and Machine Learning Coding on SAS Viya SAS Visual Investigator Health Care and Pharma SAS in Health Care Related https://communities.sas.com/t5/Base-SAS-Programming/Divide-by-0-Error-in-Macro/td-p/143296 Fields SAS Drug Development SASware Ballot Ideas Regional Groups Special Interest Groups SAS Community Denmark SANZOC CoDe SAS German SAS Visual Analytics Nederland Singapore SAS Global Forum 2017 SAS Communities Library Home / SAS Programming / Base SAS Programming / Divide by 0 Error in Macro Divide by 0 Error in Macro Solved Reply Topic Options Subscribe to RSS Feed Mark Topic as New Mark Topic as Read Float this Topic to the Top Bookmark Subscribe Printer Friendly Page « Message Listing « Previous Topic Next Topic » BN_RN17 Occasional Contributor Posts: 8 Divide by 0 Error in Macro Options Mark as New Bookmark Subscribe Subscribe to RSS Feed Highlight Print Email to a Friend Report Inappropriate Content 07-30-2014 06:53 PM I have a pretty simple macro code:%macro do_array(var=, num=); %do var_num = 1 %to # %if &var&var_num = 0 %then %do; perc_&var&var_num = 0; %end; %else %do; perc_&var&var_num = &var&var_num / total; %end; %end;%mend;Basically for all of the variables I'm just trying to get a percentage of the total. When I run it, I get an warning that I'm dividing by zero, but that's what the first step in the if statement is trying to avoid. Along
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 effi