SAS enumeration with condition

Accepted Solution Solved
Reply
Contributor
Posts: 73
Accepted Solution

SAS enumeration with condition


Hi,

I want to create a variable that enumerate each observation with one defined condition("Yes")

I have tried _N_ but nedd to add a if/where clause but this is not possible.

I want my table to look like this (a new count when New event="Yes") and if possible a retain for the last Count when New event="No"

Id                         New event      counter            

1                           Yes               1

1                           Yes               2

2                           Yes               3

2                           No                3

2                           No                3

2                           No                3

2                           Yes              4

3                           Yes              5

Thanks

Thomas


Accepted Solutions
Solution
‎12-03-2013 06:26 AM
Respected Advisor
Posts: 3,777

Re: SAS enumeration with condition

if 'new event'n eq 'Yes' then counter + 1;

View solution in original post


All Replies
Solution
‎12-03-2013 06:26 AM
Respected Advisor
Posts: 3,777

Re: SAS enumeration with condition

if 'new event'n eq 'Yes' then counter + 1;

Contributor
Posts: 73

Re: SAS enumeration with condition

Brilliant, Thanks!!

/Thomas

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 198 views
  • 3 likes
  • 2 in conversation