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 ![]()
NumOfDays = (7*int(Week_Days)) + (10*(Week_Days - int(Week_Days)));
data test;
week_days=38.6;
days=10*(week_days-floor(week_days));
weeks=floor(week_days);
num_days=(weeks*7)+days;
run;
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
I would suggest:
days =
7*int(weeks_days)
+ int(10*mod(weeks_days, 1));
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
NumOfDays = (7*int(Week_Days)) + (10*(Week_Days - int(Week_Days)));
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.