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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 2 replies
  • 394 views
  • 0 likes
  • 3 in conversation