Help using Base SAS procedures

PROC APPEND problem

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 238
Accepted Solution

PROC APPEND problem

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


Accepted Solutions
Solution
‎03-20-2012 11:35 AM
Respected Advisor
Posts: 3,124

Re: PROC APPEND problem

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


All Replies
Solution
‎03-20-2012 11:35 AM
Respected Advisor
Posts: 3,124

Re: PROC APPEND problem

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

Regular Contributor
Regular Contributor
Posts: 238

PROC APPEND problem

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?

Respected Advisor
Posts: 3,124

PROC APPEND problem

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.

Regular Contributor
Regular Contributor
Posts: 238

PROC APPEND problem

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

Respected Advisor
Posts: 3,124

PROC APPEND problem

did you try to use the 'force' option?

Regular Contributor
Regular Contributor
Posts: 238

PROC APPEND problem

Yes I did

Respected Advisor
Posts: 3,124

Re: PROC APPEND problem

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 366 views
  • 0 likes
  • 2 in conversation