BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Felix_
Obsidian | Level 7

Hello SAS Community.

I have a hopefully easier problem to solve for you:

 

PROC SQL;

CREATE TABLE rawdat.detail AS SELECT a.* FROM rawdat.detail AS a INNER JOIN rawdat.product AS B
ON a.case_id = b.case_id AND a.seq_id = b.id
ORDER BY x, y, z; QUIT;

My Problem is, that i wand to modify the table i am reading in.

 

I could solve the problem with creating another table, but thats not what i am looking for.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Create table A ... from table A ... is simply not valid SQL - so don't do it.

 

Use a Delete instead "delete .... where not exists (...)" as this is actually the result of your inner join.

 

As you can't re-create the same table with a SQL you also can't resort it directly in-itself. You could create an index instead.

 

Or -alternatively - you could do something as below

 

PROC SQL;
  CREATE view V_detail AS
    SELECT a.*
      FROM rawdat.detail  AS a 
        INNER JOIN
          rawdat.product AS B       
          ON a.case_id = b.case_id AND a.seq_id = b.id  
          ;
QUIT;

proc sort data=V_detail out=rawdat.detail;
  by x y z;
run;

 

 

View solution in original post

3 REPLIES 3
RahulG
Barite | Level 11

You can modify the existing table but you would get warning in logs. 

 

If you are okay with warning then go ahead.

Felix_
Obsidian | Level 7

Hello RahulG, thanks for the response.
The warning in the log-file is exactly my problem. I want to have a fast solution (with sql) with a clean log. Couldn't find the solution so far...

Patrick
Opal | Level 21

Create table A ... from table A ... is simply not valid SQL - so don't do it.

 

Use a Delete instead "delete .... where not exists (...)" as this is actually the result of your inner join.

 

As you can't re-create the same table with a SQL you also can't resort it directly in-itself. You could create an index instead.

 

Or -alternatively - you could do something as below

 

PROC SQL;
  CREATE view V_detail AS
    SELECT a.*
      FROM rawdat.detail  AS a 
        INNER JOIN
          rawdat.product AS B       
          ON a.case_id = b.case_id AND a.seq_id = b.id  
          ;
QUIT;

proc sort data=V_detail out=rawdat.detail;
  by x y z;
run;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 996 views
  • 1 like
  • 3 in conversation