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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 2386 views
  • 8 likes
  • 6 in conversation