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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.