I need to take three tables that I am creating in a SAS program and append them to one table. I am creating three separate tables from one main table. How do I put the three tables together?
There are two ways to append data in SAS. The first is directly in the data step with the SET statements. The second way is through the use of the PROC APPEND statement.
Make sure that the variables are the same (same names and same types) in all the datasets.
ex1.
FYI the Proc Append also works QUITE well with inserting into ODBC databases (SQL or otherwise)... so it is an alternative to using Proc SQL... the only thing that I use if the FORCE option so that I do not have to worry about having all of the variables in the SAS dataset.
So I end up with
libname MySQL odbc dsn=sqlserver datasrc="PlantReportData" BCP=YES;
Here's a tip. Proc Append is particularly useful when appending a small dataset to a large dataset. If you use the example above using the SET statement, every row from each of the datasets is read and processed. With Proc Append, only rows from the second (data=) dataset are read. So if you have one large dataset (such as a historic file) to which you are appending a smaller dataset (current weeks data for example) then Proc Append is a more efficient way of coding it. Otherwise there really isn't much difference between the 2 methods.
Another alternative method is to use the UPDATE statement instead of SET and this will update records on the master dataset with the records from the transaction dataset with matching BY values. Probably not what you need in this case though.
Enjoy.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.