BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JessSun
Calcite | Level 5

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 Smiley Happy

1 ACCEPTED SOLUTION

Accepted Solutions
P_Marty
SAS Employee

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

View solution in original post

5 REPLIES 5
JasonDiVirgilio
Quartz | Level 8


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

Peter_C
Rhodochrosite | Level 12

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

RickAster
Obsidian | Level 7

I would suggest:

   days =

      7*int(weeks_days)

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

Ksharp
Super User
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

P_Marty
SAS Employee

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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