Hello everyone,
I'm not sure how best to phrase my question, so I'll just show the input and desired output:
The input has the first observation of each class marked with a 1 in the "Set" column. The sorting of the data is obviously very important here, as I've essentially binned the observations according to a particular behaviour that we were observing, which is marked by the 1. I want for all observations until the next instance of a 1 to be in the same class.
Set |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
0 |
The desired output is as follows:
Set | Class |
1 | 1 |
0 | 1 |
0 | 1 |
1 | 2 |
0 | 2 |
0 | 2 |
0 | 2 |
1 | 3 |
1 | 4 |
0 | 4 |
0 | 4 |
Any help is much appreciated.
Cheers,
Sean
Something like this should get you started:
data want; set have; retain class 0; class=class+set; run;
RETAIN is the basic instruction to keep the value of a variable across interations in the data set.
Something like this should get you started:
data want; set have; retain class 0; class=class+set; run;
RETAIN is the basic instruction to keep the value of a variable across interations in the data set.
Then mark the useful response as a solution to your topic question.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.