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

Hi Helpers,

 

I have a table with 200 columns. I would push this table's data into a master table that has 250 columns. Column names are same. When I push the data I want unavailable columns to get a NULL value. I am using following code to push my data to a table that has same columns.

 

 

Proc SQL;
  Insert Into one.tbl_one Select * From tble_two;
Quit;

Please help.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
singhsahab
Lapis Lazuli | Level 10

Hello ,

 

In your case proc SQL insert will not work. You can use PROC APPEND procedure with FORCE options. 

 

 

proc append base=tble_one data=tble_two force;
run;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Some starter questions.  

Why have a dataset with 200+ variables, sounds like bad modelling in either SAS or Database.

Why use SQL, unless your connecting to a database, it would be easier to set two datasets in datastep.

Myurathan
Quartz | Level 8
It has 200+ variables as many units use the table for various purposes. It is pushing the data to a SQL database. There might be a better way to do it which I am not aware as I am a beginner. Thanks, @RW9.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, if you continue with the bad model, and continue to use SQL, then your only option is to put the variables you want to insert into the code:

proc sql;
  insert into one.tbl_one (var1,var2,var3...)
  select * From tble_two;
quit;

SQL wasn't designed to be used with lots of variables, so its a chore to work with if you have a bad model.  Vice versa, SAS datastep is easier to work with more variables.

singhsahab
Lapis Lazuli | Level 10

Hello ,

 

In your case proc SQL insert will not work. You can use PROC APPEND procedure with FORCE options. 

 

 

proc append base=tble_one data=tble_two force;
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 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.

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
  • 4 replies
  • 1377 views
  • 0 likes
  • 3 in conversation