04-28-2016 12:15 PM
i have two small data sets a & b. a has 1 variable and nine observations. b has 5 variables and 1 observation. there are no commonalities between the two data sets. how can i combine the two datasets to produce a new dataset c with six variables and 9 observations? by the way i am olorire.
04-28-2016 12:28 PM
It depends on how you want the values of the variables resulting. If the values from the one observation set are to only appear once then you can use a data step merge.
merge a b;
If you want all of the obeservations to have the values from the one observation set then you would want an SQL cartesian (fancy work everything in one set combined with everything in the other) join.
create table want as
select a.*, b.*
from a join b;
04-28-2016 12:39 PM
Would this example match your intention?
/* Create test datasets */ data a; do i=1 to 9; output; end; run; data b; array x (11:15); run; /* Combine the two datasets */ data want; set a; if _n_=1 then set b; run;
@ballardw: Did you mean "from a cross join b;" (or shorter: "from a, b;") ?