> My code looks like this
> data set1 set2;
> input A $1 B 2.2 C 3.2;/*A can only take a or b*/
> if A = 'a' then do;
> keep a x;
> output set1;
> if A = 'b' then do;
> keep a y;
> output set2;
> I simply want to keep only TWO variables in the resulting subsets. But the
> result is set1 also retains y flooded with missing values, while set2 has
> variable included full of missing values as well.
> I know the solution is to use Keep= in the Data statement when 'declaring'
> the two data sets. Could somebody explain why my original code does not
> Paula D
Yes, because "keep" statements in datasteps are not conditionally
executed. In other words, by virtue of the fact that they are there then
they take effect. The same goes for "drop" and "retain" and "length".
Also there is no way you can have one keep statement associated with one
dateset while another with another datastep unless you use the "keep="
against the datasets themselves.