Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wildcards in keep in a data step

Tags:

sas

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;
like image 839
statquant Avatar asked Jan 22 '13 14:01

statquant


1 Answers

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.

like image 156
itzy Avatar answered Sep 27 '22 02:09

itzy