BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5
Data ex1;
Input number ;
Cards;
3
9
22
34
49
3
33
50
12
23
34
48
;
If we take range 50 how to create sequence number 50 group wise like see below

Number seq

3. 1
9. 1
22. 1
34. 1
49. 1
3. 2
33. 2
50. 2
12. 3
23. 3
34. 3
48. 3
;

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

What if a value was over 50? What if your data looks like this?

 

Data ex1;
Input number ;
Cards;
3
9
22
34
49
3
33
50
51
12
23
34
48
;
thanikondharish
Calcite | Level 5
More than 50 value is .(missing)
PeterClemmensen
Tourmaline | Level 20

See if this works for you 🙂

 

data ex2(drop=lagnum);
    set ex1;
    if _N_=1 then seq=1;
    lagnum=lag1(number);
    if lagnum gt number then seq+1;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 590 views
  • 0 likes
  • 2 in conversation