Open 1to1 left.csv | Open 1to1 right.csv |
*To import the data;
proc import datafile = 'C:/1to1 left.csv' out = l_data dbms = csv replace;
getnames = yes;
run;
proc import datafile = 'C:/1to1 right.csv' out = r_data dbms = csv replace;
getnames = yes;
run;
Option 1: Add rows using proc append
* The Veggies and Fruits variable needs to be under the same name; * Rename the Veggies variable to be Veggies_Fruits; * Rename the Fruits variable to be Veggies_Fruits; * The results are saved in the l_data dataset, the base dataset; proc append base = l_data (rename = (Veggies = Veggies_Fruits)) data = r_data (rename = (Fruits = Veggies_Fruits)); run; |
Option 2: Add rows using the data step
* The Veggies and Fruits variable needs to be under the same name; * Rename the Veggies variable to be Veggies_Fruits; * Rename the Fruits variable to be Veggies_Fruits; data add_rows; set l_data (rename = (Veggies = Veggies_Fruits)) r_data (rename = (Fruits = Veggies_Fruits)); run; |
Option 3: Add rows using proc sql
* The Veggies and Fruits variables do not need to be renamed; * Select all the columns from l_data and all columns from r_data; * The union statement produces all unique rows from both datasets; proc sql; create table sql_add_rows as select * from l_data union select * from r_data ; quit; |
Functions referenced:
More information:
--- The End ---