BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BlayLay
Obsidian | Level 7

Hi Everyone,

 

I'm trying to figure out how to calculate Parts-Per-Minute (PPM) in SAS. I have Quantity (formatted as a number) and Duration (formatted as TIME. with HH:MM:SS) within SAS. I'm trying to create the PPM variable.

 

In excel, the formula is PPM=Quantity/(Duration*24*60) however, this formula is erroring out in SAS. Below is an example of the table and what PPM should be equal to.

 

QuantityDurationPPM
2150:10:0021.50

 

My data step that is erroring looks like this:

 

DATA WORK.TEST;
SET WORK.TEST;
PPM = Quantity/(Duration*24*60);
RUN;

 

And the error message I'm receiving says: "NOTE: Invalid numeric data, Duration=' 0:07:40' , at line 64 column 18."

 

I'm assuming I need to format the Duration differently, but am not entirely sure. Any help would be greatly appreciated.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

According to the log, Duration column is a character variable. You need to convert it to a numeric time variable :

 

Duration2=input(Duration,time7.)/60; /* Duration in minutes */

View solution in original post

2 REPLIES 2
gamotte
Rhodochrosite | Level 12

Hello,

 

According to the log, Duration column is a character variable. You need to convert it to a numeric time variable :

 

Duration2=input(Duration,time7.)/60; /* Duration in minutes */

PaigeMiller
Diamond | Level 26

Your value for duration is not a number, it is a text string, and you can't divide by a text string.

 

You have to convert this text string to a number

 

duration1 = input(duration,time7.);

Then you have the a numeric variable which contains the number of seconds in the duration. So to get the PPM, you want to divide by DURATION1/60.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 743 views
  • 0 likes
  • 3 in conversation