11-27-2012 04:28 PM
I have a dataset A that contains one observation and one variable (NMaxBlocks). I created dataset C by joining datasetA with datasetB, and dataset B did not contain the variable NMaxBlocks. Because B did not originally contain the variable NMaxBlocks, all observations in C that were originally in B now contain "." for the variable NMaxBlocks. I want all observations in C that contain "." because they were originally part of B to contain the value for NMaxBlocks that originally appeared in A. (See attached exerpt of output from C- all "." in NMaxBlocks need to contain 4 from NMAxBlocks in the last observation in the dataset). I know there is a simple way to do this, but I am not enough of an experienced SAS user to know how to do this yet. Any ideas?
11-27-2012 05:09 PM
There are several ways to accomplish this, here's one using multiple SET statements within a DATA step.
DATA WORK.C ;
IF _N_ = 1 THEN SET WORK.A ;
SET WORK.B ;
11-27-2012 05:10 PM
Perhaps you would be better off learning how to combine A and B, rather than fixing the problem later. If you are using a DATA step, it would be:
if _n_=1 then set A;
If you are using SQL:
proc sql noprint;
create table C as select * from A, B;
You would no longer have that single observation at the end, where the contents of A matches nothing from B.