DATA Step, Macro, Functions and more

SAS table insert into Oracle by Data Step

Reply
Occasional Contributor
Posts: 10

SAS table insert into Oracle by Data Step

Hello,

i want to insert a SAS Table into Oracle. Normally i use PROC SQL. But in this case i must recode or query every row in the SAS table - and after this the row should be inserted or not in Oracle.

This i want to do (with pseudo-code):


read until sas_base_table is EOF

  "recode/do something with" the sas_base_row

  if sas_base_row is a hit then
    insert into oracle_table
  else
   DO NOTHING
  end if

end read


How can i do that? Is there somewhere perhabs an example?

Thank you very much
Best regards
George

Super User
Super User
Posts: 7,039

Re: SAS table insert into Oracle by Data Step

[ Edited ]

Why ?

 

If you want to write to Oracle using a data step then make a libref that points to your Oracel schema.

libname MYDB oracle .... ;

Generate the rows you want to insert. For example you could use a conditional OUTPUT statement in your data step to select the rows to insert.

data toadd ;
  set ....
  if ... then output;
run;

Then insert them.

proc append base=mydb.mytable data=toadd force;
run;

 

Occasional Contributor
Posts: 10

Re: SAS table insert into Oracle by Data Step

Thank you very much for your help.

Best regards
George
Ask a Question
Discussion stats
  • 2 replies
  • 600 views
  • 1 like
  • 2 in conversation