02-01-2016 01:13 PM
New to SAS coding so if you need more details please let me know
I am getting the following error when to running a code is EG 4.3
ERROR: CLI open cursor error: ERROR: Divide by 0
Sample of data set
ID Card_Sales Card_Used
001 25 5
002 10 8
003 7 2
004 0 0
SAS Code I am using:
Card_Used / Card_Sale as Ratio
Any assistance would be greatly appreicated.
02-01-2016 01:18 PM
If you were working in a DATA step, the best way would be to use an IF/THEN statement:
if Card_Sale then Ratio = Card_Used / Card_Sale;
That would skip the processing when Card_Sale is either zero or missing. Since it looks like you are working with SQL instead, you would need to add a CASE statement to assign Ratio a missing value when Card_Sale is zero or missing.
Need further help from the community? Please ask a new question.