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!!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.