BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Jbraun
Fluorite | Level 6

I am trying to do a panel-data analysis and get this message: 

 

ERROR: Not enough observations with non-missing values for model statement Model 1 in cross section ID=XXXX.

 

Looking at my data I think it is because the outcome variable has the value 1 for retirement but 0 in all other cases and therefore it probably can't figure out when to consider 0 as an outcome = non-retirement. 

 

Therefore I want to change all values in outcome to missing if it is zero, except if the last year is 0, then it should keep the zero:

 

Have:

ID Year Outcome

1  2018 0

1  2019 0

1  2020 1

2  2019 0

2  2020 1

3  2019 0

3  2020 0

3  2021 0

 

Want:

Have:

ID Year Outcome

1  2018 .

1  2019 .

1  2020 1

2  2019 .

2  2020 1

3  2019 .

3  2020 .

3  2021 0

 

I hope someone can help with this - probably fairly simple - request. 

Thank you for an awesome community!

 

Kind regards,

Jacob

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Assuming that the data is sorted by ID and year:

 

data want;
  set have;
  by id;
  if not last.id and Outcome = 0 then do;
    Outcome = .;
  end;
run;

untested

View solution in original post

6 REPLIES 6
andreas_lds
Jade | Level 19

Assuming that the data is sorted by ID and year:

 

data want;
  set have;
  by id;
  if not last.id and Outcome = 0 then do;
    Outcome = .;
  end;
run;

untested

Jbraun
Fluorite | Level 6

Brilliant, thanks!

PaigeMiller
Diamond | Level 26

@Jbraun 

Changing zeros to missing can change whatever analysis you are doing and make it gibberish. Without knowing further details about what you are doing, I consider this to be a very poor practice.

 

(And by the way, an analysis that ignored zeros led to a decision that led to the launch of Space Shuttle Challenger, which then exploded due to a failure of the O-rings because; a grievous error if ever there was one).

--
Paige Miller
Jbraun
Fluorite | Level 6

Yes, can make gibberish or correct the data, depending on the context. I know the NASA case. I promise I will not crash any rockets. 

ballardw
Super User

I'm going to chime into this late. The Topic of "change 0 to non-missing" and the body with "ERROR: Not enough observations with non-missing values for model statement Model 1 in cross section ID=XXXX." means that assigning additional missing values as requested in the Want data set is not going to address the issue. Adding more missing values means that you have even fewer "non-missing".

 

The topic title does not reflect the request either.

 

I would be somewhat interested in seeing the model code you submitted because your narrative makes it sound that the model is poorly designed at best and maybe incorrect completely for the data.

 

 


@Jbraun wrote:

I am trying to do a panel-data analysis and get this message: 

 

ERROR: Not enough observations with non-missing values for model statement Model 1 in cross section ID=XXXX.

 

Looking at my data I think it is because the outcome variable has the value 1 for retirement but 0 in all other cases and therefore it probably can't figure out when to consider 0 as an outcome = non-retirement. 

 

Therefore I want to change all values in outcome to missing if it is zero, except if the last year is 0, then it should keep the zero:

 

Have:

ID Year Outcome

1  2018 0

1  2019 0

1  2020 1

2  2019 0

2  2020 1

3  2019 0

3  2020 0

3  2021 0

 

Want:

Have:

ID Year Outcome

1  2018 .

1  2019 .

1  2020 1

2  2019 .

2  2020 1

3  2019 .

3  2020 .

3  2021 0

 

I hope someone can help with this - probably fairly simple - request. 

Thank you for an awesome community!

 

Kind regards,

Jacob


 

Jbraun
Fluorite | Level 6

the title was misleading, I wanted to change 0 to missing. It did not solve the issue, but I found out that I needed to change some missing values in some of the independent variables. It puzzled me a bit because the PROC PANEL documentation says that missing values will just be ignored, but it seems that this was not the case. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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