Hi, anyone did this question can help and confirm this? Should the 'Average/Typical' be 'TA' (see screen capture)? I got error message when run the ls means/pdiff=control; statement with the value as 'Average/Typical', which is not the value in the Heating_QC column, that value in fact is 'TA' (see screen capture).
The error message when run with a value of 'Average/Typical' is like this (and there was no Dunnett test results (there was only results for tukey test).
73 ods select lsmeans diff diffplot controlplot; 74 proc glm data=STAT1.ameshousing3 75 plots(only)=(diffplot(center) controlplot); 76 class Heating_QC; 77 model SalePrice=Heating_QC; 78 lsmeans Heating_QC / pdiff=all 79 adjust=tukey; 80 lsmeans Heating_QC / pdiff=control('Average/Typical') 81 adjust=dunnett; 82 format Heating_QC $Heating_QC.; 83 title "Post-Hoc Analysis of ANOVA - Heating Quality as Predictor"; 84 run; ERROR: Cannot find control level for effect Heating_QC. 85 quit;
The code works when change the value to 'TA' and produces the results of Dunnett test.
ods graphics;
ods select lsmeans diff diffplot controlplot;
proc glm data=STAT1.ameshousing3
plots(only)=(diffplot(center) controlplot);
class Heating_QC;
model SalePrice=Heating_QC;
lsmeans Heating_QC / pdiff=all
adjust=tukey;
lsmeans Heating_QC / pdiff=control('TA')
adjust=dunnett;
format Heating_QC $Heating_QC.;
title "Post-Hoc Analysis of ANOVA - Heating Quality as Predictor";
run;
quit;
title;
Hi, As you have noticed, the datasets in the ST1 course use formats. Formats allow you to print different values than the values stored in the dataset. Often, formatted values are longer and more descriptive than the actual data values. In your case, the actual data value stored in the dataset is "TA", and its formatted version is "Average/Typical".
The code doesn't work because the $Heating_QC format is not defined. Make sure you have defined the $Heating_QC format (and all the formats in general) every time you open up SAS.
You can do that by running the program st100d05.sas every time you open us SAS. This calls programs st100d01.sas - st100d04.sas, which define the datasets and formats.
Your code should work as originally written with "Average/Typical" once the formats are defined.
Yes, you should specify only valid formatted values for the PDIFF=CONTROL option. It looks like it is coded/formatted as TA so that should be the value.
However, my test result is different from the results in course video (see screen capture), do I get different dataset?
The ordering of the tables is different, but I do not see a difference in the values. The table will automatically be ordered according to the sort order of the formatted values. I suspect if you were running an example that you missed some Proc FORMAT code which set those values you tried to use initially and are shown in the other table.
Hi, As you have noticed, the datasets in the ST1 course use formats. Formats allow you to print different values than the values stored in the dataset. Often, formatted values are longer and more descriptive than the actual data values. In your case, the actual data value stored in the dataset is "TA", and its formatted version is "Average/Typical".
The code doesn't work because the $Heating_QC format is not defined. Make sure you have defined the $Heating_QC format (and all the formats in general) every time you open up SAS.
You can do that by running the program st100d05.sas every time you open us SAS. This calls programs st100d01.sas - st100d04.sas, which define the datasets and formats.
Your code should work as originally written with "Average/Typical" once the formats are defined.
Thanks a lot @JackieJ_SAS ! So the reason was I did not run the format program before I did that question. In fact I noticed the format; statement in the code and knew the format was not applied, and I have even tried options fmtsearch=(stat1); and did not work, then I had a wrong conclusion that lsmean pdiff=; statement does not allow a formatted value and need the original values. I'll run st100d05 and see the results for that question 😀, again, thanks a lot for let me know this, really helpful!
Awesome! I'm glad the response helped!
Regarding your comment about the FMTSEARCH option.. The st100d05.sas program saves the formats to a format library named work.formats, not stat1.formats. That is why your FMTSEARCH option code did not work. (Though- it's cool that you tried!)
You can list all the formats in a particular library (and convince yourself that work.formats exists) by running this code below after you have run the st100d05.sas program. This prints all the formats in work.formats to the results window:
proc format fmtlib library=work.formats;
run;
If you try running the code above, but you insert "stat1.formats" for "work.formats", the code throws an error, since stat1.formats does not exist.
This is a bit too much information, but if you would like to save the STAT1 formats permanently, you can run the program st100d05.sas then run the program below. This copies the file "work.formats" to a file "formats.sas7bcat" that is located in the STAT1 Data folder.
proc catalog catalog = work.formats;
copy out = stat1.formats;
run;
Then, instead of having to run st100d05.sas every time you open SAS, you can use this code below in order to access the stat1.formats format catalog. This is the same code you mentioned in your reply:
options fmtsearch = (stat1);
Good luck with the course!
Thanks a lot for this information! I will need to learn and try these steps (save my formats in particular library and re-use them) in near future I think! Thank you and all then best 😀
@JackieJ_SAS wrote:
...
Then, instead of having to run st100d05.sas every time you open SAS, you can use this code below in order to access the stat1.formats format catalog. This is the same code you mentioned in your reply:
options fmtsearch = (stat1);
Good luck with the course!
Note that over the years SAS made it easier to update the values of options like FMTSEARCH that take a list of values by adding the APPEND and INSERT options.
So to add the STAT1.FORMATS catalog to the end of the FMTSEARCH list of catalogs use one of these two statements.
options append=fmtsearch=stat1;
options append=fmtsearch=stat1.formats;
You should end up with FMTSEARCH option that looks like this:
293 %put %sysfunc(getoption(fmtsearch)); (WORK LIBRARY STAT1)
https://documentation.sas.com/doc/en/pgmsascdc/v_063/lesysoptsref/p1q9ay0ai0h2ein1n68qxomnm3q7.htm
The APPEND= system option adds a new value to the end of the current value of the AUTOEXEC, CMPLIB, FMTSEARCH, SASHELP, MSG, MAPSGFK, SASAUTOS, SASSCRIPT, or SET system options. The INSERT= system option adds a new value as the first value of one of these system options.
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.