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 -,

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 225 views
  • 0 likes
  • 2 in conversation