BookmarkSubscribeRSS Feed
rodrichiez
Quartz | Level 8

Hello community,

 

I'm tying to do an insert with a where clause to filter the operators that I've already have on the destination table.

 

The code is:

 

PROC SQL;
INSERT INTO LIBNAME.EMPLOYEES AS T1
(OPERATOR,
CODE,
NAME,
POSITION,
DEPARTMENT,
STATUS)
SELECT *
FROM WORK.QUERY AS T2
WHERE T1.OPERATOR NE T2.OPERATOR;
QUIT;

 

ERROR 79-322: Expecting a SELECT.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

 

 

2 REPLIES 2
art297
Opal | Level 21

What are you trying to insert? Here is an example of using the insert statement:

 

proc sql;
  create table test as
    select * from sashelp.class
      where age eq 12
  ;
  
   insert into test
     select * from sashelp.class
      where age ge 15
 ;
quit;

Art, CEO, AnalystFinder.com

 

kiranv_
Rhodochrosite | Level 12

you can do this in two steps an example is shown

/* dataset 1*/
data have1;
input name $ age;
datalines;
bill 20
sam 10

;
/* dataset 2*/
data have2;
input name $ age;
datalines;
bill 20


;
/* create a temp table*/
proc sql;
create table have3 as
select * from have1
where trim(name) not in(select trim(name) from have2);
/* then insert into final table*/
proc sql;
insert into have2(name, age)
select * from have3;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1303 views
  • 2 likes
  • 3 in conversation