Help using Base SAS procedures

Proc Append

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

Proc Append

Hi ,

I have two datasts and want to append them together( variable attributes are same in both the datasets)

DATASET1(BASE=)

ID   IN1  OUT1   IN2    OUT2    IN3    OUT3     IN4     OUT4

DATASET2(DATA=)

ID  IN1   OUT1  IN2   OUT2

When I try to append these two datasets I get messages in the LOG that

IN3  is not initialized

OUT3    is not initialized

IN4     is not initialized

OUT4  is not initialized

Should I use Force Option????

BUT I READ FROM DOCUMENTATION

"You must use the FORCE option with PROC APPEND when the DATA= data set contains a variable that is not in the BASE= data set. If you modify the program to include the FORCE option, then it successfully concatenates the files.

THAT IS NOT THE CASE WITH ME.....

DATA=dataset contains common variables always but not as many as those in the BASE dataset

Thanks


Accepted Solutions
Solution
‎06-26-2013 05:45 PM
Super User
Super User
Posts: 7,080

Re: Proc Append

Posted in reply to robertrao

FORCE doesn't apply in this case.  You will not get "uninitialized" messages, but you will get warnings about the missing variables.

Here is some example data:

data one two (keep=id in1 out1 in2 out2);

input (id in1 out1 in2 out2 in3 out3 in4 out4) (1.);

cards;

123456789

;

proc append base=one data=two ;

run;


NOTE: Appending WORK.TWO to WORK.ONE.

WARNING: Variable in3 was not found on DATA file.

WARNING: Variable out3 was not found on DATA file.

WARNING: Variable in4 was not found on DATA file.

WARNING: Variable out4 was not found on DATA file.

NOTE: There were 1 observations read from the data set WORK.TWO.

NOTE: 1 observations added.

NOTE: The data set WORK.ONE has 2 observations and 9 variables.

If you reverse the two datasets then you will need the FORCE option, but the extra variables will NOT be added to the base dataset.

proc append base=two data=one force ;

run;

NOTE: Appending WORK.ONE to WORK.TWO.

WARNING: Variable in3 was not found on BASE file. The variable will not be added to the BASE file.

WARNING: Variable out3 was not found on BASE file. The variable will not be added to the BASE file.

WARNING: Variable in4 was not found on BASE file. The variable will not be added to the BASE file.

WARNING: Variable out4 was not found on BASE file. The variable will not be added to the BASE file.

NOTE: FORCE is specified, so dropping/truncating will occur.

NOTE: There were 1 observations read from the data set WORK.ONE.

NOTE: 1 observations added.

NOTE: The data set WORK.TWO has 2 observations and 5 variables.

View solution in original post


All Replies
Solution
‎06-26-2013 05:45 PM
Super User
Super User
Posts: 7,080

Re: Proc Append

Posted in reply to robertrao

FORCE doesn't apply in this case.  You will not get "uninitialized" messages, but you will get warnings about the missing variables.

Here is some example data:

data one two (keep=id in1 out1 in2 out2);

input (id in1 out1 in2 out2 in3 out3 in4 out4) (1.);

cards;

123456789

;

proc append base=one data=two ;

run;


NOTE: Appending WORK.TWO to WORK.ONE.

WARNING: Variable in3 was not found on DATA file.

WARNING: Variable out3 was not found on DATA file.

WARNING: Variable in4 was not found on DATA file.

WARNING: Variable out4 was not found on DATA file.

NOTE: There were 1 observations read from the data set WORK.TWO.

NOTE: 1 observations added.

NOTE: The data set WORK.ONE has 2 observations and 9 variables.

If you reverse the two datasets then you will need the FORCE option, but the extra variables will NOT be added to the base dataset.

proc append base=two data=one force ;

run;

NOTE: Appending WORK.ONE to WORK.TWO.

WARNING: Variable in3 was not found on BASE file. The variable will not be added to the BASE file.

WARNING: Variable out3 was not found on BASE file. The variable will not be added to the BASE file.

WARNING: Variable in4 was not found on BASE file. The variable will not be added to the BASE file.

WARNING: Variable out4 was not found on BASE file. The variable will not be added to the BASE file.

NOTE: FORCE is specified, so dropping/truncating will occur.

NOTE: There were 1 observations read from the data set WORK.ONE.

NOTE: 1 observations added.

NOTE: The data set WORK.TWO has 2 observations and 5 variables.

Super Contributor
Posts: 1,041

Re: Proc Append

Okie..........

We get warnings about missing variables. Is that Right? Can we go ahead with those warnings ???????Can I ignore those warnings?????

Thanks

Super User
Super User
Posts: 7,080

Re: Proc Append

Posted in reply to robertrao

Only you know what fields you require, so the decision to ignore the warning is yours.

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 2864 views
  • 3 likes
  • 2 in conversation