Hello,
I tried including the formatted control value in the control option of the LSMEANS with adjust=dunnett. Got the error message " ERROR: Cannot find control level for effect Pedu." I double-checked the code as well as the spelling of the formatted values (Please see it in the Proc Format), everything looked fine to me. I am using SAS studio to run this program.
Please let me know of any solutions/suggestions on this matter. My original code is included below.
Thanks in advance!
Sharon
proc format;
value fpedu
1= “below college”
2= “college”
3 = “graduate school”;
run;
proc glm data=ad;
format pedu fpedu.;
class pedu;
model readscore = Pedu;
lsmeans pedu/pdiff=control("graduate school") adjust=dunnett;
title 'One Way ANOVA for testing differences in reading score across parent education groups';
run;
I think I figured it out. The problem comes from the quotes used in proc format. They are not normal double quotes. These characters have become part of the formatted values. Replace them with normal double quotes and your code should work.
Show us the full LOG, with nothing chopped out, from the PROC FORMAT statement all the way down to (and including all) the NOTES below PROC GLM.
To make sure the log is formatted properly, copy it as text and then paste it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 libname model "/folders/myfolders/Model/"; NOTE: Libref MODEL was successfully assigned as follows: Engine: V9 Physical Name: /folders/myfolders/Model 74 data ad; 75 set model.Anova_data; 76 run; NOTE: There were 200 observations read from the data set MODEL.ANOVA_DATA. NOTE: The data set WORK.AD has 200 observations and 12 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 77 proc format; 78 value fpedu 79 1= “below college” 80 2= “college” 81 3 = “graduate school”; NOTE: Format FPEDU has been output. 82 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 83 84 proc glm data=ad; 85 format pedu fpedu.; 86 class pedu; 87 model readscore = Pedu; 88 lsmeans pedu/pdiff=control("graduate school") adjust=dunnett; 89 title 'One Way ANOVA for testing differences in reading score across parent education groups'; 90 run; ERROR: Cannot find control level for effect Pedu. 91 92 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 104
Does variable PEDU take on value 3 in data set AD? Show us the results of running PROC FREQ on variable PEDU from data set AD.
@sharonC: I'm sure @PGStats has found the solution. Note that PROC FREQ output does normally not display quotes around character values or format labels. The tricky thing is that the VALUE statement of PROC FORMAT accepts both quoted and unquoted strings (for backward compatibility reasons I think; the same holds for a couple of other SAS statements). Otherwise, the PROC FORMAT step would have thrown a helpful error message indicating that something is wrong with the format labels.
Thank you so much!
Just tried and it worked!
Regards,
Sharon
Yes, Just posted the frequency tables
Thanks!
Sharon
Then I don't know what the problem is. Maybe someone else can jump in and offer an explanation, or you can contact SAS Technical Support.
Yes, Thank you!
I will.
Regards,
Sharon
You might want to check that readscore is not missing for the pedu=3 group.
I think I figured it out. The problem comes from the quotes used in proc format. They are not normal double quotes. These characters have become part of the formatted values. Replace them with normal double quotes and your code should work.
Thank you so much!
Just tried and it worked!
Regards,
Sharon
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.