Help using Base SAS procedures

[coding] adding observing order in dataset

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 128
Accepted Solution

[coding] adding observing order in dataset

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.

orderlocationL
127123
227121
130344
230345
330334
430355
133366
233345
333334
433355
533345
633334
733355

Accepted Solutions
Solution
‎11-16-2012 12:12 PM
Super Contributor
Posts: 1,636

Re: [coding] adding observing order in dataset

data want;

  set have;

    by location notsorted;

if first.location then order=0;

order+1;

run;

View solution in original post


All Replies
Solution
‎11-16-2012 12:12 PM
Super Contributor
Posts: 1,636

Re: [coding] adding observing order in dataset

data want;

  set have;

    by location notsorted;

if first.location then order=0;

order+1;

run;

Frequent Contributor
Posts: 128

Re: [coding] adding observing order in dataset

@Linlin. Thank you!!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 138 views
  • 0 likes
  • 2 in conversation