is it possible to use wildcards in the keep
of a data step? I want to do the following (left join of A on B keeping variables x and y and all variables starting with a):
data C;
merge A(in=a)
B(keep= x y var* in=b);
by x y;
if a;
run;
Yes, use :
.
data C;
merge A(in=a)
B(keep=x y a: in=b);
by x y;
if a;
run;
(It's not a good idea to say in=a
if you have a variable named a
.)
If you have variables with sequential numbers, like a1
, a2
, ..., aN
, you can write a1-aN
. And if you want a set of adjacent columns (say varX
, varY
, and varZ
are physically adjacent in the data set), you can say varX--varZ
. The difference between these two examples is just whether you use one dash or two.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With