70 likes | 208 Views
Techie Tips SAS Dates / Times / Datetimes. Beverley Lawson, Dalhousie Family Medicine. Dates. regdate (from an excel file) 19990809. reg_date (formated sasdate) 09AUG1999. reg_date = input(put(regdate, 8.), yymmdd8.); format reg_date date9.; run;. Time. Obs regt ime
E N D
Techie TipsSAS Dates / Times / Datetimes Beverley Lawson, Dalhousie Family Medicine SHRUG February 6, 2009
Dates regdate (from an excel file) 19990809 reg_date (formated sasdate) 09AUG1999 reg_date = input(put(regdate, 8.), yymmdd8.); format reg_date date9.; run;
Time Obs regtime 1 1343 2 1015 3 0254 Obs regtimereghour regmin 1 1343 13 43 2 1015 10 15 3 0254 02 54 length reghour $2 regmin $ 2; reghour = substr(regtime, 1,2); regmin = substr(regtime, 3,2);
More time …Next add a semi colon & change to a sastime … length nregtime $5; nregtime = reghour||":"||regmin; run; n_regtime = input(nregtime, time5.); format n_regtime hhmm5.; run; regtimereghourregmin 1343 13 43 1015 10 15 0254 02 54 • n_regtime • 13:43 • 10:15 17:51
SAS datetime reg_date 25JAN1999 07MAR1999 18APR1999 regsasdt = dhms (reg_date, 0, 0, n_regtime); put regsasdt datetime.; format regsasdt datetime.; run; n_regtime 17:51 23:12 22:01 regsasdt 25JAN99:17:51:00 07MAR99:23:12:00 18APR99:22:01:00 +
Wait times(e.g ED visits) wait_rd = disch_sasdt - regsasdt; format wait_rd hhmm5.; label wait_rd = 'ED wait time from registration to discharge'; run; disch_sasdt 25JAN99:21:16:00 08MAR99:04:15:00 19APR99:00:20:00 regsasdt 25JAN99:17:51:00 07MAR99:23:12:00 18APR99:22:01:00 wait_rd 3:25 5:03 2:19 -