13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

732 Date, Timestamp, and Interval Data 4 Chapter 25proc sql;connect to oracle ( &PTCONN);/*execute ( drop table EMP_ATTENDANCE) by oracle;*/execute ( create table EMP_ATTENDANCE ( EMP_NAME VARCHAR2(10),arrival_timestamp TIMESTAMP, departure_timestamp TIMESTAMP ) ) by oracle;execute ( insert into EMP_ATTENDANCE values(’John Doe’, systimestamp, systimestamp+.2) ) by oracle;execute ( insert into EMP_ATTENDANCE values(’Sue Day’, TIMESTAMP’1980-1-12 10:13:23.33’,TIMESTAMP’1980-1-12 17:13:23.33’ )) by oracle;quit;libname oraoracle &CONNproc contents data=ora.EMP_ATTENDANCE; run;proc sql;/* reading TIMESTAMP datatype */select * from ora.EMP_ATTENDANCE;quit;/* appending to TIMESTAMP datatype */data work.new;EMP_NAME=’New Bee1’;ARRIVAL_TIMESTAMP=’30sep1998:14:00:35.00’dt;DEPARTURE_TIMESTAMP=’30sep1998:17:00:14.44’dt; output;EMP_NAME=’New Bee2’;ARRIVAL_TIMESTAMP=’30sep1998:11:00:25.11’dt;DEPARTURE_TIMESTAMP=’30sep1998:14:00:35.27’dt; output;EMP_NAME=’New Bee3’;ARRIVAL_TIMESTAMP=’30sep1998:08:00:35.33’dt;DEPARTURE_TIMESTAMP=’30sep1998:17:00:35.10’dt; output;<strong>for</strong>mat ARRIVAL_TIMESTAMP datetime23.2;<strong>for</strong>mat DEPARTURE_TIMESTAMP datetime23.2;run;title2 ’After append’;proc append data=work.new base=ora.EMP_ATTENDANCE ; run;proc print data=ora.EMP_ATTENDANCE ; run;/* updating TIMESTAMP datatype */proc sql;update ora.EMP_ATTENDANCE set ARRIVAL_TIMESTAMP=. where EMP_NAME like ’%Bee2%’ ;select * from ora.EMP_ATTENDANCE ;delete from ora.EMP_ATTENDANCE where EMP_NAME like ’%Bee2%’ ;select * from ora.EMP_ATTENDANCE ;/* OUTPUT: Creating a brand new table using Data Step*/data work.sasdsfsec; c_ts=’30sep1998:14:00:35.16’dt; k=1; output;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!