BookmarkSubscribeRSS Feed
powder
Calcite | Level 5

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

1 REPLY 1
Linlin
Lapis Lazuli | Level 10

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1618 views
  • 0 likes
  • 2 in conversation