Hi everyone, really don't know how to search such kind of question, so I start a new discussion.
Please see the dataset below, I have colum "location" and 'L' only, I want to create a new column "order".
"L"s were repeated measurements for different "location"s. My question is how I can create column 'order' by coding? Thanks.
order | location | L |
1 | 27 | 123 |
2 | 27 | 121 |
1 | 30 | 344 |
2 | 30 | 345 |
3 | 30 | 334 |
4 | 30 | 355 |
1 | 33 | 366 |
2 | 33 | 345 |
3 | 33 | 334 |
4 | 33 | 355 |
5 | 33 | 345 |
6 | 33 | 334 |
7 | 33 | 355 |
data want;
set have;
by location notsorted;
if first.location then order=0;
order+1;
run;
data want;
set have;
by location notsorted;
if first.location then order=0;
order+1;
run;
@Linlin. Thank you!!
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.