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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2439 views
  • 8 likes
  • 6 in conversation