🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 06-20-2019 12:21 PM
(969 views)
Hi All, I have below dummy data set. I would like to achieve below result in the last column. Result column in T or R depending on the consecutive zero of the row DATA TEST; INPUT ID T1 T2 T3 T4 T5 T6 T7; CARDS; 1 1 1 1 0 1 1 1 2 1 1 0 0 1 1 1 3 1 1 0 0 0 1 1 4 1 1 0 1 1 1 1 5 0 1 1 1 1 1 1 6 0 0 1 1 1 1 1 ; RUN; Result will look like as below 1 1 1 1 0 1 1 1 T 2 1 1 0 0 1 1 1 R 3 1 1 0 0 0 1 1 R 4 1 1 0 1 1 1 1 T 5 0 1 1 1 1 1 1 T 6 0 0 1 1 1 1 1 R
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are the values only 0 and 1? Are any missing?
If so you could try converting them to a string and checking the string for the pattern.
if index(cats(of t1-t7),'000') then result='T';
else result='R';
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
This seems like a scenario where you could use ARRAY processing if you need to worry about consecutive values. What about data like this:
1 1 1 1 0 1 1 1 T 2 1 1 0 0 1 1 1 R 3 1 1 0 0 0 1 1 R 4 1 1 0 1 1 1 1 T 5 0 1 1 1 1 1 1 T 6 0 0 1 1 1 1 1 R 7 1 1 1 1 1 1 1 T 8 1 0 1 0 1 0 1 ??
I assume that 7 would be a T, but what about 8 -- it has three 0 values, but not consecutive.
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are the values only 0 and 1? Are any missing?
If so you could try converting them to a string and checking the string for the pattern.
if index(cats(of t1-t7),'000') then result='T';
else result='R';