DATA Step, Macro, Functions and more

Output Required with specific condition as shown below.

Reply
Contributor
Posts: 36

Output Required with specific condition as shown below.

Hi SAS team,

By taking the reference value "NO" as base for the field "Tx" we need to filter out specific set of values.

we need to check for specific value of "No" and we need to look for previous value which should be "Yes". For All  these records if the Num field value is missing for any record then that set of "yes " along with "No" records should pull in the output. As shown in the below example.

 

 

data Have;

input sub week1$ tx$ seq num;

cards;

01 w0 no   1  .

01 w1 yes  1  1

01 w2 yes  2  1

01 w3 no   3  .

01 w4 yes  4  .

01 w5 no   5  .

01 w7 no   6  .

01 w8 yes  7  .

01 w9 yes  8  1

01 w10 no  9  .

01 w11 yes 10 1

;

run;

 

output Should be in this way;

sub

week1

tx

seq

num

1

w4

yes

4

 

1

w5

no

5

 

1

w8

yes

7

 

1

w9

yes

8

1

1

w10

no

9

 

 

 

Regards,

Raju

PROC Star
Posts: 1,218

Re: Output Required with specific condition as shown below.

Just to Clarify. If an observation has tx="No" and num=. you want this record outputted along with all previous observations where tx="Yes" up until tx "No"? Smiley Happy

Contributor
Posts: 36

Re: Output Required with specific condition as shown below.

yes, addition to that for all those records if Num field value is missing for any record then that set of "yes" along with "No" record should pull in the output.

Contributor
Posts: 36

Re: Output Required with specific condition as shown below.

Hi All,

 

Did any got the solution for above query ?

 

Regards,

raju

Ask a Question
Discussion stats
  • 3 replies
  • 130 views
  • 0 likes
  • 2 in conversation