[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Difference between time points
From:       Andrew Smith <a.j.smith () READING ! AC ! UK>
Date:       2023-01-22 14:20:11
Message-ID: 6103729043355860.WA.a.j.smithreading.ac.uk () listserv ! uga ! edu
[Download RAW message or body]

Try something like this: 


data character_dates_yuk ;
  length baseline_str followup_str $24 ;
  infile datalines pad truncover ;
  input baseline_str $char24. @26 followup_str $char24. ;
  datalines ;
1/10/2014 12:21          1/19/2014 16:33
1/21/2014 10:24          1/24/2014 12:19
1/14/2014 5:23           1/16/2014 4:57
1/2/2018 5:02            1/2/2018 5:05
;

options datestyle=mdy; 

data use_proper_datetime_values ;
  set character_dates_yuk ;
  baseline = input(baseline_str, anydtdtm. ) ;
  followup = input(followup_str, anydtdtm. ) ;
  days     = intck('dtday', baseline, followup ) ;
  hours    = intck('hour',  baseline, followup ) ;
  days_arith  = (followup-baseline)/(24*60*60) ;
  hours_arith = (followup-baseline)/(60*60) ;
  format baseline followup e8601dt. ;
run;

options nocenter linesize=132 ;

proc print data= use_proper_datetime_values ;
run;


/*

Difference between time points
I need to take the difference between two time points as days as well as hours.
https://listserv.uga.edu/scripts/wa-UGA.exe?A2=2301C&L=SAS-L&D=0&P=267929275
https://listserv.uga.edu/scripts/wa-UGA.exe?A2=SAS-L;9307afdf.2301C&S=

DATESTYLE= System Option
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/nlsref/n0cmg3tjkn6zmbn1od6pna244zm7.htm

ANYDTDTMw. Informat
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p1hsn1ji141r4zn0z3xm2dthop6a.htm

INTCK Function
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p1md4mx2crzfaqn14va8kt7qvfhr.htm

*/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic