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

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;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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.

PG

View solution in original post

13 REPLIES 13
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
sharonC
Calcite | Level 5
Thanks for reply! Please see the complete log below.
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        
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
FreelanceReinh
Jade | Level 19

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

sharonC
Calcite | Level 5

Thank you so much!

Just tried and it worked!

Regards,

Sharon

sharonC
Calcite | Level 5

Yes, Just posted the frequency tables

Thanks!

Sharon

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
sharonC
Calcite | Level 5

Yes, Thank you!

I will.

Regards,

Sharon

PGStats
Opal | Level 21

You might want to check that readscore is not missing for the pedu=3 group.

PG
sharonC
Calcite | Level 5
Yes, they are not missing.
I also tried all three groups, none of them worked.
Sharon

PGStats
Opal | Level 21

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.

PG
sharonC
Calcite | Level 5

Thank you so much!

Just tried and it worked!

Regards,

Sharon

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

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.

Discussion stats
  • 13 replies
  • 2265 views
  • 3 likes
  • 4 in conversation