Aman Mathur
Aman Mathur

Reputation: 719

Column copy to another dataset in sas

I want to copy only 2 out of 7 columns in 'B' dataset form 'A' dataset

dataset A has (p,q,r,s,t,u,v) I want to copy p,q,t in a new dataset B.

Upvotes: 0

Views: 846

Answers (3)

kittymad
kittymad

Reputation: 93

This is a more efficient way to do it:

data B;
set A (keep=p q t);
run;

Because the keep option in the set statement indicates that only these columns are read to start with. Using keep outside the set statement will still read in the columns, but drop them after.

Upvotes: 2

criticalth
criticalth

Reputation: 438

What do you mean copy two colums ? Do dataset B already exists ? If thats the case you need to simply merge the two files and use keep statemaent when reading them. If you need to create new data set its even simpler

data B;
set A;
keep p q t;
run;

Hope it helps. If you need the merge plz post and I will explain furthermore

Upvotes: 0

Aman Mathur
Aman Mathur

Reputation: 719

We can use 'keep' keyword.

data B;
set A;
keep p q t;
run;

Upvotes: 0

Related Questions