10-31-2017 09:17 AM
I have one dataset that contains 1,000 observations and 50 variables - Data A.
I also have another dataset with only one observation and 30 variables - Data B.
The variables in Data B are parmeters that I want to add to all observations in Data A.
I tried to merge/set the two datasets but it only gives me first observation in A with the 1 observation in B and the other observations with missing value.
As You can see in the photo, Data A ends with variable P1000 and Data B starts with variable SM.
My question is, How do I dulplicate the one observation in B so all the observations in A will have it as a variable?
10-31-2017 09:44 AM
10-31-2017 09:37 AM
Consider these two methods:
data a; input var1 var2 var3; cards; 1 2 3 4 5 6 7 8 9 ; run; data b; input var4 var5; cards; 10 11 ; run; data want1; set a; _x_ = 1; set b point=_x_; run; proc sql; create table want2 as select * from a,b; quit;
The point=method rereads dataset b in every iteration, and therefore overrides the problem caused by the automatic "set to missing" that happens at the start of a datastep iteration.
SQL will always build a cartesian product on its own.
Need further help from the community? Please ask a new question.