02-23-2016 10:13 PM
Hello. I am new to SAS and apologize if this is elementary. I am using NHANES data and already have a dataset in place for a 3-year period. That said, I just found the same data I need for 3 more years. How do I add this data to my existing dataset?
02-23-2016 11:00 PM
The operation is known as Appending, and it depends.
If your data sets have the exact same data structure, including variable names/types then you can do an append. If not, you should ideally make them the same and then append.
Append stacks data, adds more rows, same variables.
Merges bring the data side by side, adds more columns/variables.
For appending you can use PROC APPEND or SET in a Data step.
This is an example of an append, except I'm appending the same data twice.
data double_class; set sashelp.class sashelp.class; run;
02-24-2016 01:49 AM
PROC APPEND or a DATA step with several datasets in the SET statement will do nicely.
The difference between the two methods is: the DATA step will do a complete rewrite of the dataset, while APPEND will append physically to the existing dataset.
APPEND is less tolerant about changes in the data structure, though.
02-24-2016 01:15 PM