DATA Step, Macro, Functions and more

Calculate hours based off business days in a month

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Calculate hours based off business days in a month

Hello!

I am working with some data to calculate FTE hours based off business days in a given month (excluding weekends and standard US holidays). 

My data is layed out as follows - 

For example

PRID

ProjectID

ResourceID

AllocYear

AllocJan

AllocFeb

AllocMar

AllocApr

AllocMay

AllocJun

AllocJul

AllocAug

AllocSep

AllocOct

AllocNov

AllocDec

6002198

5728091

5181017

2017

32

32

36.8

32

35.2

35.2

16

0

0

0

0

0

I need to determine based off the current date(7/20/17) - what is the correct month variable to use(AllocJul) and what year (AllocYear) to use.

 and then calculate the percentage of FTE hours based on the following

Business days in current month (July 2017 has 20 days) and multiply that (20 *8) 8 being the standard number of hours a full time FTE works per day and then divide that by the number in the current Alloc month column.

 

 

It would be (20*8) = 160  and 16 for AllocJul in the example above

Would be 160/16 = 10

 

Is there a way in sas to do this?

Thank you in advance for your help!

Angie Miller


Accepted Solutions
Solution
‎07-28-2017 01:39 PM
Super User
Posts: 7,856

Re: Calculate hours based off business days in a month

Posted in reply to amiller9702

Use an Array:

data want (keep=prid projectid resourceid alloc);
set have;
where allocyear = year(today);
array months {*} allocjan-allocdec;
alloc = months{month(today())};
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎07-28-2017 01:39 PM
Super User
Posts: 7,856

Re: Calculate hours based off business days in a month

Posted in reply to amiller9702

Use an Array:

data want (keep=prid projectid resourceid alloc);
set have;
where allocyear = year(today);
array months {*} allocjan-allocdec;
alloc = months{month(today())};
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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