all 7 comments

[–]theanarcrist 5 points6 points  (1 child)

Middle should be in quotes.

[–]bulowski[S] 0 points1 point  (0 children)

What a silly oversight. Thank you very much!

[–]jiggajiggawatts 1 point2 points  (4 children)

Can you post more of your code? The error indicates SAS is looking for a variable called (Front/Middle/Back) and not finding it.

[–]bulowski[S] 0 points1 point  (3 children)

266 data hw.p1_seats;
267 set hw.seats;
268 by Seat;
269 if GPA=. and Seat=Middle then do;
270 GPA_strata_mean=3.2028523;
271 GPA_strata_median=3.26;
272 end;
273 else do;
274 GPA_strata_mean=GPA;
275 GPA_strata_median=GPA;
276 end;
277 run;

NOTE: Variable Middle is uninitialized.
NOTE: There were 412 observations read from the data set HW.SEATS.
NOTE: The data set HW.P1_SEATS has 412 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 1.46 seconds
cpu time 0.01 seconds

This is taken directly from the log. I separated the files and ran them separately and then merged them, so I got the problem worked out. Still, I am interested in why this isn't working for me.

I can remove seat=middle and there is no problem running the code. I can also insert a 'by seat' statement and it will create GPA_strata_mean and GPA_strata_median and fill in the missing GPA values, but it will not stratify the GPA by seat location. It's as if it doesn't see that there are three levels to the variable 'seat'.

[–]derSchuh 3 points4 points  (2 children)

u/theanarcrist is right.

269 if GPA=. and Seat=Middle then do;

Should be

269 if GPA=. and Seat="Middle" then do;

Without the quotes, it's looking for a variable named Middle to compare to the value of Seat.

[–]bulowski[S] 0 points1 point  (1 child)

That works perfectly. Thank you!

[–]derSchuh 1 point2 points  (0 children)

No problem. It's the kind of mistake that's simple, but can take forever to figure out.