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

Hi everyone.

I'd like to insert columns from table A into a new table called ''new",  but got errors: File work.new.date does not exist.

Could you please give me some suggestions?

Thanks in advance!

 

 

PROC SQL;

INSERT INTO new

SELECT variable1, variable2, variable3

FROM A;

QUIT;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@runrunbunny wrote:

Hi everyone.

I'd like to insert columns from table A into a new table called ''new",  but got errors: File work.new.date does not exist.

Could you please give me some suggestions?

Thanks in advance!

 

 

PROC SQL;

INSERT INTO new

SELECT variable1, variable2, variable3

FROM A;

QUIT;

 

 


Try

PROC SQL;
   Create table new as
   SELECT variable1, variable2, variable3
   FROM A;
QUIT;

The insert as you attempted requires the data set to exist, Create table creates the new set

 

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

Sounds like you don't have a dataset named NEW yet.  So instead of trying to append observations to an existing dataset you want to make a new dataset.  In SQL you would use CREATE TABLE for that.

create table new as 
  select variable1, variable2, variable3
  from a
;

Or in regular SAS code a simple data step.

data new;
  set a;
  keep variable1-variable3;
run;
runrunbunny
Obsidian | Level 7
Thank you for your answer!
ballardw
Super User

@runrunbunny wrote:

Hi everyone.

I'd like to insert columns from table A into a new table called ''new",  but got errors: File work.new.date does not exist.

Could you please give me some suggestions?

Thanks in advance!

 

 

PROC SQL;

INSERT INTO new

SELECT variable1, variable2, variable3

FROM A;

QUIT;

 

 


Try

PROC SQL;
   Create table new as
   SELECT variable1, variable2, variable3
   FROM A;
QUIT;

The insert as you attempted requires the data set to exist, Create table creates the new set

 

runrunbunny
Obsidian | Level 7
Thanks a lot!
Reeza
Super User
INSERT adds new rows usually, not new columns.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1329 views
  • 1 like
  • 4 in conversation