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.
Quantity | Duration | PPM |
215 | 0:10:00 | 21.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
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 */
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 */
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.