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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 824 views
  • 1 like
  • 4 in conversation