/* Program 1: how to transfer Date, Time in character format to date/time format? */ data test; date='05/04/00'; time='10:05'; run; data new; set test; sasdate1=input(date, mmddyy8.); sasdate2=sasdate1; sastime1=input(time, time5.); sastime2=sastime1; datetim1=input(put(sasdate1,date7.)||':'||time,datetime16.); datetim2=datetim1; ** created sasdate2, sastime2, datetim2 for display purposes only **; run; proc print data=new; var sasdate1 sasdate2 sastime1 sastime2 datetim1 datetim2; format sasdate2 mmddyy8. sastime2 hhmm5. datetim2 datetime16.; run; /* How to deal with time variable in SAS/Graph? */ data one; input startime time5. count; if startime gt '12:00't then date='30sep92'd; else date='01oct92'd; datetime=dhms(date,hour(startime),minute(startime), second(startime)); cards; 16:00 12.3 17:00 5.7 18:00 8.6 19:00 9.0 20:00 15.7 21:00 10.5 22:00 8.1 23:00 1.5 0:00 11.3 1:00 6.6 2:00 3.5 3:00 7.6 4:00 2.4 5:00 13.8 6:00 14.0 7:00 4.9 8:00 5.0 run; proc print; var startime datetime; run; proc gplot data=one; plot count*datetime / haxis='30sep92:16:00'dt to '01oct92:08:00'dt by hour2; format datetime tod5.; run;
Tuesday, September 10, 2013
Dealing SAS Date/time
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment