DATA Step, Macro, Functions and more

i have a dataset like below and need to make it like the second one

Reply
Contributor VRD
Contributor
Posts: 33

i have a dataset like below and need to make it like the second one

btext1btext2btext3trt1trt2trt3
sample1XXXXXXXXX
sample1ana1XXXXXXXXX
sample1ana1ban1XXXXXXXXX
sample1ana1ban2XXXXXXXXX
sample1ana1ban3XXXXXXXXX
sample1ana1ban4XXXXXXXXX

texttrt1trt2trt3
sample1XXXXXXXXX
ana1XXXXXXXXX
ban1XXXXXXXXX
ban2XXXXXXXXX
ban3XXXXXXXXX
ban4XXXXXXXXX

can any one help me in this?

Respected Advisor
Posts: 3,124

Re: i have a dataset like below and need to make it like the second one

Look up Coalescec() function and Keep/Drop statement.

Haikuo

Super User
Super User
Posts: 7,401

Re: i have a dataset like below and need to make it like the second one

Per Hai.kuo, this is covered in this post: https://communities.sas.com/message/226275#226275

Trusted Advisor
Posts: 1,204

Re: i have a dataset like below and need to make it like the second one

data want(drop=btext2 btext3);

set have;

if btext2 ne ' ' and btext3=' ' then btext1=btext2;

if btext3 ne ' ' then btext1=btext3;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 161 views
  • 0 likes
  • 4 in conversation