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

I have 2 tables I want to append and not sure how to do it. Example of table 1

who        svcd          svdesc          admission            count

1111        1            major                no                      2

1111        1            major              yes                    1

2222        3            extreme            no                    5

2222        3            extreme            yes                    1

table 2

who            svcd        svdesc          admission              count

national          1            major              no                      6000

national          1            major              yes                        12

national          3            extreme          no                      5000

national          3            extreme          yes                        5

Table 2 only have a total of 10 rows and I want to append it to table 1 which has like 139k rows.

I tried a merge but have no primary key to really use that I can see

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Question: for variable 'who', are they the same type(char) in both tables? if not, proc append is not gonna cut it.  if yes, are they the same length? if not, truncating may happen.

Otherwise,

proc append base=table1 data=table2 force;

run;

or use proc datasets or proc sql ; insert into

Regards,

Haikuo

View solution in original post

7 REPLIES 7
Haikuo
Onyx | Level 15

Question: for variable 'who', are they the same type(char) in both tables? if not, proc append is not gonna cut it.  if yes, are they the same length? if not, truncating may happen.

Otherwise,

proc append base=table1 data=table2 force;

run;

or use proc datasets or proc sql ; insert into

Regards,

Haikuo

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

The who is text in both but 1 is 9 characters and the other is set to 8. i guess i could change it to 9 would that help?

Haikuo
Onyx | Level 15

if base table has the longer length, you don't need to do anything, otherwise, you need to modify the length in base table to the length in the table to be appended.

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

The proc append did not work due to length. How do I do an insert into?

Haikuo
Onyx | Level 15

did you try to use the 'force' option?

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

Yes I did

Haikuo
Onyx | Level 15

Are you certain that it did not 'append' or it did but with a warning about 'length' problem? If it was the later and the warning really bothers you, you can turn it off by adding option 'NOWARN' after 'force'.

It would be ideal if  you could post your code along with your error log.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1243 views
  • 0 likes
  • 2 in conversation