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!!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.