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).

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 674 views
  • 0 likes
  • 2 in conversation