BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KS99
Obsidian | Level 7

Hi all, 

 

Thank you in advance, 

 

I have a panel data like the following: 

ID CUSIP YEAR
2 201647 1994
3 20030N 1987
3 20030N 1988
3 20030N 1989
3 20030N 1991
3 20030N 1996
3 20030N 1997
3 20030N 1998
4 073902 1992
4 073902 1993
6 561232 1995
8 552848 2002
8 552848 2004
8 552848 2007
8 62945J 1987
8 62945J 1988
8 929903 1991
8 929903 1992
8 929903 1994
12 08658U 1995
12 08658U 1996
12 08658U 1997
13 001547 2007
13 001547 2008
13 001547 2011
13 001547 2012
13 001547 2014 

 

By group ID-CUSIP, I want to endow a same value for consecutive years. And, if there is a jump in year, consecutive years from that year on will be endowed another yet same value. 

 

The results I want to obtain are: 

ID CUSIP YEAR Newvar
2 201647 1994      1
3 20030N 1987     1
3 20030N 1988     1
3 20030N 1989     1
3 20030N 1991     2
3 20030N 1996     3
3 20030N 1997     3
3 20030N 1998     3
4 073902 1992     1
4 073902 1993     1
6 561232 1995     1
8 552848 2002    1
8 552848 2004    2
8 552848 2007    3
8 62945J 1987    1
8 62945J 1988    1
8 929903 1991    1
8 929903 1992    1
8 929903 1994    2
12 08658U 1995  1
12 08658U 1996  1
12 08658U 1997  1
13 001547 2007  1
13 001547 2008  1
13 001547 2011  2
13 001547 2012  2
13 001547 2014  3

 

I sincerely thank you all for your wonderful help! 

 

KS -, 

 

1 ACCEPTED SOLUTION
2 REPLIES 2
KS99
Obsidian | Level 7
Thank you. Sir, for helping out.
It works wonderfully!

KS -,

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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