## Converting from weeks to days

Solved
Occasional Contributor
Posts: 8

# Converting from weeks to days

Hi everyone,

I have a variable called "Weeks_Days" which is in weeks with the decimal part indicating number of days (e.g. 20.3 = 20 weeks and three days = 20*7+3 = 143 days)

Is that a way to convert those data in days?

10    ==> 70

20.3 ==> 143

38.6 ==> 272

Cheers,

Jess

Accepted Solutions
Solution
‎05-02-2013 11:50 AM
New Contributor
Posts: 2

## Re: Converting from weeks to days

NumOfDays = (7*int(Week_Days)) + (10*(Week_Days - int(Week_Days)));

All Replies
Contributor
Posts: 46

## Re: Converting from weeks to days

data test;
week_days=38.6;
days=10*(week_days-floor(week_days));
weeks=floor(week_days);
num_days=(weeks*7)+days;
run;

Valued Guide
Posts: 2,191

## Re: Converting from weeks to days

Posted in reply to JasonDiVirgilio

Sounds like a goid reason to learn about compiling user-defined functions with PROC FCMP

Unless there is a base-7 counting solution like for octal and binary

peterC

Contributor
Posts: 22

## Re: Converting from weeks to days

I would suggest:

days =

7*int(weeks_days)

+ int(10*mod(weeks_days, 1));

Super User
Posts: 10,787

## Re: Converting from weeks to days

```data _null_;
a=10; aa=int(a)*7 + mod(a*10,10);
put a= aa=;
a=20.3; aa=int(a)*7 + mod(a*10,10);
put a= aa=;
a=38.6; aa=int(a)*7 + mod(a*10,10);
put a= aa=;
run;
```

Ksharp

Solution
‎05-02-2013 11:50 AM
New Contributor
Posts: 2

## Re: Converting from weeks to days

NumOfDays = (7*int(Week_Days)) + (10*(Week_Days - int(Week_Days)));

🔒 This topic is solved and locked.

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

Discussion stats
• 5 replies
• 392 views
• 8 likes
• 6 in conversation