BookmarkSubscribeRSS Feed
Raj_C
Obsidian | Level 7

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

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

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"? 🙂

Raj_C
Obsidian | Level 7

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.

Raj_C
Obsidian | Level 7

Hi All,

 

Did any got the solution for above query ?

 

Regards,

raju

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 703 views
  • 0 likes
  • 2 in conversation