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

My data is a panel of industry-years. Some industry-years have a value of 1 for an indicator variable "PERSISTENT." (Otherwise, PERSISTENT is missing.) Some industries do not have any years for which PERSISTENT is 1, and the years in which PERSISTENT takes on a value of 1 may vary by industry.

How can I recode PERSISTENT such that it takes on values of 0 before the industry-year observation that currently has a 1 AND takes on values of 1 for all industry-years afterward?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

data want;

by industry;

retain flag;

if first.industry then flag=0;

if persistent=1 then flag=1;

run;

View solution in original post

4 REPLIES 4
Reeza
Super User

Show what your data looks like, is it long or wide?

yanagi
Calcite | Level 5
IndustryYearPERSISTENT
111992
111993
111994
1119951
111996
111997
111998
111999
112000
112001
112002
112003
112004
112005
112006

That's an example of what the data looks like. I guess that's long?

Reeza
Super User

data want;

by industry;

retain flag;

if first.industry then flag=0;

if persistent=1 then flag=1;

run;

yanagi
Calcite | Level 5

Thank you so much. I was vastly overthinking it (thought I needed to do an array).

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1250 views
  • 0 likes
  • 2 in conversation