DATA Step, Macro, Functions and more

Proc APPEND

Reply
N/A
Posts: 0

Proc APPEND

data period2A;
infile 'c:\Cwa\period2_sales_data_A.dat';
Input TransactionID $1-8
DateofSale $9-18
LaptopModel $19-24
UnitsSold 25-27
Warranty 28;
proc print data=period2A;
run;

data period2B;
infile 'c:\Cwa\period2_sales_data_B.dat';
Input TransactionID $1-8
TimeofSale $9-16;
proc print data=period2B;
run;

proc append base = period2A data= period2B ;
run;

The LOG wiindow after running the append command says :


301 proc append base = period2A data= period2B ;
302 run;

NOTE: Appending WORK.PERIOD2B to WORK.PERIOD2A.
WARNING: Variable TimeofSale was not found on BASE file. The variable will not be added to the BASE
file.
WARNING: Variable DateofSale was not found on DATA file.
WARNING: Variable LaptopModel was not found on DATA file.
WARNING: Variable UnitsSold was not found on DATA file.
WARNING: Variable Warranty was not found on DATA file.
ERROR: No appending done because of anomalies listed above. Use FORCE option to append these files.
NOTE: 0 observations added.
NOTE: The data set WORK.PERIOD2A has 245 observations and 5 variables.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.07 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.

what am i mistaken in ?

kindly guide.

mark
Super Contributor
Posts: 359

Re: Proc APPEND

Proc append simply does what it says, adds one dataset to the end of the other. The FORCE option will make it append with differing variables, but your data has none in common.

My guess is that you want to merge the datasets not append.

so sort both then do.

data new;
merge period2A period 2B;
by TransactionID;
RUN;
N/A
Posts: 0

Re: Proc APPEND

I used the follwing code :

libname sc 'c:\Cwa';
data sc.period2A;
infile 'c:\Cwa\period2_sales_data_A.dat';
Input TransactionID $1-8
DateofSale $9-18
LaptopModel $19-24
UnitsSold 25-27
Warranty 28;
proc sort data=period 2A;
By TransactionID;
Run;
proc print data=period2A;
run;


data sc.period2B;
infile 'c:\Cwa\period2_sales_data_B.dat';
Input TransactionID $1-8
TimeofSale $9-16;
proc sort data=period 2B;
By TransactionID;
Run;
proc print data=period2B;
run;


data sc.new;
merge period2A period 2B;
by TransactionID;
RUN;
proc print data = new;
Run;


A Sample of the Log window showing errors is :

18 proc sort data=period 2B;
-
22
200
ERROR: File WORK.PERIOD.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ASCII, BUFFNO, DANISH, DATA,.... )

ERROR 200-322: The symbol is not recognized and will be ignored.
19 By TransactionID;
20 Run;

51 data sc.new;
52 merge period2A period 2B;
-
22
200
ERROR: File WORK.PERIOD.DATA does not exist.
ERROR: File WORK.B.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, END,
_DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

53 by TransactionID;
54 RUN;

what mistake have i made ?

kindly guide .

mark

NOTE: The SAS System stopped processing this step because of errors.
Super Contributor
Posts: 359

Re: Proc APPEND

Read your log. You can't have a space in the middle of a dataset name.
Ask a Question
Discussion stats
  • 3 replies
  • 269 views
  • 0 likes
  • 2 in conversation