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!!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.