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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.