I have bed times for a sample of 6000 chidren in hrs:minutes:secs (e.g. 21:35:03), and I would like to calculate mean(s) and also use the bed time as a dependent variable in Multilevel model. My question is can someone help me with the sas code for the means especially when some of the bed times are past midnight, and others are before? Lastly how can I use this variable as a dependent var?
Thank you kindly.
Post test data in the form of a datastep.
This seems to be a learning excercise, consult your learning materials and the manual:
ok. So your data looks like this right?
data have; format bed_time time.; input bed_time :time.; datalines; 22:46:20 00:57:15 00:36:00 23:02:20 21:22:00 20:10:15 19:45:12 03:04:00 ;
But how do you know if a childs bed time is recorded before/after midnight? Do you have some indicator of that?
I propose that you set a "cutoff time" that is used to determine if the bed time is before or after midnight. If the bedtime is after midnight, you need to add 24 hours (=60*60*24 seconds) so that the "bed time function" is continuous. For example, the following program uses Draycut's data step and adds 24 hours to any times that are before noon:
data want; set have; noon = 60*60*12; /* cutoff value */ t = ifn(bed_time <= noon, bed_time+2*noon, bed_time); /* add 24 hours if time before noon */ drop noon; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.