Desktop productivity for business analysts and programmers

problems dividing two columns

Reply
N/A
Posts: 1

problems dividing two columns

Using SAS EG 4.3 when I go to divide the two columns the results returned is always zero.  I've tried different formats, etc.  However the same two columns can be added, subtracted, multiplied no issues.  See code and output below for details.  Thanks in advance.

Code:

t1.Region,

          /* TC_Tasks */

            (SUM(t1.MeasureCount)) FORMAT=11. LABEL="TC_Tasks" AS TC_Tasks,

          /* TC_Tasks_Met */

            (SUM(CASE

               WHEN t1.HourDefferedCount <= 4 And MeasureCount = 1 THEN 1

               ELSE 0

            END)) FORMAT=11. LABEL="TC_Tasks_Met" AS TC_Tasks_Met,

          /* TC_Tasks_Met1 */

            ((SUM(CASE

               WHEN t1.HourDefferedCount <= 4 And MeasureCount = 1 THEN 1

               ELSE 0

            END)) / (SUM(t1.MeasureCount))) FORMAT=BEST10.9 LABEL="TC_Tasks_Met1" AS TC_Tasks_Met1,

TC_TasksTC_Tasks_MetTC_Tasks_Met1
5944920
180512750
179112420
5684460
246216560

Super Contributor
Posts: 1,636

Re: problems dividing two columns

Hi,

I made up a dataset and ran your code. I don't have the problem you described and I ran the code in EG4.3

data test;

input MeasureCount HourDefferedCount;

cards;

1          3

2          4

3          1

0          5

1          6

0          1

1          2

1          3

0          4

1          5

0          6

1          7

;

proc sql;

  select /* TC_Tasks */

            (SUM(t1.MeasureCount)) FORMAT=11. LABEL="TC_Tasks" AS TC_Tasks,

          /* TC_Tasks_Met */

            (SUM(CASE

               WHEN t1.HourDefferedCount <= 4 And MeasureCount = 1 THEN 1

               ELSE 0

            END)) FORMAT=11. LABEL="TC_Tasks_Met" AS TC_Tasks_Met,

          /* TC_Tasks_Met1 */

            ((SUM(CASE

               WHEN t1.HourDefferedCount <= 4 And MeasureCount = 1 THEN 1

               ELSE 0

            END)) / (SUM(t1.MeasureCount))) FORMAT=BEST10.9 LABEL="TC_Tasks_Met1" AS TC_Tasks_Met1

           from test as t1;

quit;

The SAS System

TC_TasksTC_Tasks_MetTC_Tasks_Met1
1130.27272727

and your code is the same as

proc sql;

  select /* TC_Tasks */

            (SUM(t1.MeasureCount)) FORMAT=11. LABEL="TC_Tasks" AS TC_Tasks,

          /* TC_Tasks_Met */

            (SUM(CASE

               WHEN t1.HourDefferedCount <= 4 And MeasureCount = 1 THEN 1

               ELSE 0

            END)) FORMAT=11. LABEL="TC_Tasks_Met" AS TC_Tasks_Met,

          /* TC_Tasks_Met1 */

            calculated TC_Tasks_Met

           / calculated TC_Tasks FORMAT=BEST10.9 LABEL="TC_Tasks_Met1" AS TC_Tasks_Met1

  from test as t1;

quit;

Linlin

Ask a Question
Discussion stats
  • 1 reply
  • 170 views
  • 0 likes
  • 2 in conversation