SlideShare a Scribd company logo
SAS tutorial 0524
proc anova;
class A B S;
model y=S|A|B;
test h=A e= S*A;
run;

The same as glm (但是比較沒用...)
Example
title 'Unbalanced Two-Way   2 1 28 . 23 34 42 13
Analysis of Variance';      2 2 . 34 33 31 . 36
data a;                     2 3 3 26 28 32 4 16
  input drug disease @;     3 1 . . 1 29 . 19
   do i=1 to 6;             3 2 . 11 9 7 1 -6
     input y @;             3 3 21 1 . 9 3 .
     output;                4 1 24 . 9 22 -2 15
   end;                     4 2 27 12 12 -5 16 15
   datalines;               4 3 22 7 25 5 12 .
   1 1 42 44 36 13 19 22    ;
   1 2 33 . 26 . 33 21
   1 3 31 -3 . 25 25 24
4x3 2-way
code
ods graphics on;
 proc glm;
   class drug disease;
   model y=drug disease drug*disease /ss3;
      contrast 'drug 1 vs 2' drug 1 -1 0 0;
      contrast 'drug 1 vs 3' drug 1 0 -1 0;
      contrast 'drug 1 vs 4' drug 1 0 0 -1;
   lsmeans drug/ pdiff=all adjust=tukey;
 run;
ods graphics off;
Result
Interaction plot
Dummy variable
• Category variable
• Set reference group
• Set N-1 d.variables:
  – 1 if xij belongs to the group specified
  – 0 if xij belongs to other groups

• E.g. variable drug in the example:
   –   0 0 0 => drug=1
   –   1 0 0 => drug=2
   –   0 1 0 => drug=3
   –   0 0 1 => drug=4
Data
Result (is the same)
Why use d.v. coding?




     http://www.sas.com/offices/NA/canada/downloads/presen
     tations/VancouverMay11/Variable.pdf
If you cannot run contrast
          analysis──
• Check coefficients
• Separate main effects and interactions into
  different models.
• e.g. 2-way ANOVA with interaction:
  – model y = A B;
    (contrasts for main effects)
  – model y = A*B;
    (contrasts for interaction)

More Related Content

More from WenSheng Chang

futureNo52
futureNo52futureNo52
futureNo52
WenSheng Chang
 
Sas plot
Sas plotSas plot
Sas plot
WenSheng Chang
 
Sas reg multi
Sas reg multiSas reg multi
Sas reg multi
WenSheng Chang
 
Sas reg simple
Sas reg simpleSas reg simple
Sas reg simple
WenSheng Chang
 
Sas corr
Sas corrSas corr
Sas corr
WenSheng Chang
 
1129 sas實習課
1129 sas實習課1129 sas實習課
1129 sas實習課
WenSheng Chang
 
Sas tutorial 1018
Sas tutorial 1018Sas tutorial 1018
Sas tutorial 1018
WenSheng Chang
 
Sas tutorial glm2
Sas tutorial glm2Sas tutorial glm2
Sas tutorial glm2
WenSheng Chang
 
Sas tutorial glm1
Sas tutorial glm1Sas tutorial glm1
Sas tutorial glm1
WenSheng Chang
 
SAS 0412
SAS 0412SAS 0412
SAS 0412
WenSheng Chang
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
WenSheng Chang
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
WenSheng Chang
 
Science p79 -- polished
Science p79 -- polishedScience p79 -- polished
Science p79 -- polished
WenSheng Chang
 

More from WenSheng Chang (15)

futureNo52
futureNo52futureNo52
futureNo52
 
Sas plot
Sas plotSas plot
Sas plot
 
Sas reg multi
Sas reg multiSas reg multi
Sas reg multi
 
Sas reg simple
Sas reg simpleSas reg simple
Sas reg simple
 
Sas corr
Sas corrSas corr
Sas corr
 
1129 sas實習課
1129 sas實習課1129 sas實習課
1129 sas實習課
 
Sas tutorial 1018
Sas tutorial 1018Sas tutorial 1018
Sas tutorial 1018
 
Sas tutorial glm2
Sas tutorial glm2Sas tutorial glm2
Sas tutorial glm2
 
Sas tutorial glm1
Sas tutorial glm1Sas tutorial glm1
Sas tutorial glm1
 
Regression ci
Regression ciRegression ci
Regression ci
 
SAS 0412
SAS 0412SAS 0412
SAS 0412
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
0925 sas實習課
0925 sas實習課0925 sas實習課
0925 sas實習課
 
Science p79 -- polished
Science p79 -- polishedScience p79 -- polished
Science p79 -- polished
 

Recently uploaded

Adhd Medication Shortage Uk - trinexpharmacy.com
Adhd Medication Shortage Uk - trinexpharmacy.comAdhd Medication Shortage Uk - trinexpharmacy.com
Adhd Medication Shortage Uk - trinexpharmacy.com
reignlana06
 
CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1
CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1
CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1
rishi2789
 
Medical Quiz ( Online Quiz for API Meet 2024 ).pdf
Medical Quiz ( Online Quiz for API Meet 2024 ).pdfMedical Quiz ( Online Quiz for API Meet 2024 ).pdf
Medical Quiz ( Online Quiz for API Meet 2024 ).pdf
Jim Jacob Roy
 
Clinic ^%[+27633867063*Abortion Pills For Sale In Tembisa Central
Clinic ^%[+27633867063*Abortion Pills For Sale In Tembisa CentralClinic ^%[+27633867063*Abortion Pills For Sale In Tembisa Central
Clinic ^%[+27633867063*Abortion Pills For Sale In Tembisa Central
19various
 
Artificial Intelligence Symposium (THAIS)
Artificial Intelligence Symposium (THAIS)Artificial Intelligence Symposium (THAIS)
Artificial Intelligence Symposium (THAIS)
Josep Vidal-Alaball
 
Cell Therapy Expansion and Challenges in Autoimmune Disease
Cell Therapy Expansion and Challenges in Autoimmune DiseaseCell Therapy Expansion and Challenges in Autoimmune Disease
Cell Therapy Expansion and Challenges in Autoimmune Disease
Health Advances
 
CHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdf
CHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdfCHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdf
CHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdf
rishi2789
 
Post-Menstrual Smell- When to Suspect Vaginitis.pptx
Post-Menstrual Smell- When to Suspect Vaginitis.pptxPost-Menstrual Smell- When to Suspect Vaginitis.pptx
Post-Menstrual Smell- When to Suspect Vaginitis.pptx
FFragrant
 
CHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdf
CHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdfCHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdf
CHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdf
rishi2789
 
Outbreak management including quarantine, isolation, contact.pptx
Outbreak management including quarantine, isolation, contact.pptxOutbreak management including quarantine, isolation, contact.pptx
Outbreak management including quarantine, isolation, contact.pptx
Pratik328635
 
Ear and its clinical correlations By Dr. Rabia Inam Gandapore.pptx
Ear and its clinical correlations By Dr. Rabia Inam Gandapore.pptxEar and its clinical correlations By Dr. Rabia Inam Gandapore.pptx
Ear and its clinical correlations By Dr. Rabia Inam Gandapore.pptx
Dr. Rabia Inam Gandapore
 
pathology MCQS introduction to pathology general pathology
pathology MCQS introduction to pathology general pathologypathology MCQS introduction to pathology general pathology
pathology MCQS introduction to pathology general pathology
ZayedKhan38
 
8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx
8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx
8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx
Holistified Wellness
 
10 Benefits an EPCR Software should Bring to EMS Organizations
10 Benefits an EPCR Software should Bring to EMS Organizations   10 Benefits an EPCR Software should Bring to EMS Organizations
10 Benefits an EPCR Software should Bring to EMS Organizations
Traumasoft LLC
 
Ketone bodies and metabolism-biochemistry
Ketone bodies and metabolism-biochemistryKetone bodies and metabolism-biochemistry
Ketone bodies and metabolism-biochemistry
Dhayanithi C
 
Cervical Disc Arthroplasty ORSI 2024.pptx
Cervical Disc Arthroplasty ORSI 2024.pptxCervical Disc Arthroplasty ORSI 2024.pptx
Cervical Disc Arthroplasty ORSI 2024.pptx
LEFLOT Jean-Louis
 
Osteoporosis - Definition , Evaluation and Management .pdf
Osteoporosis - Definition , Evaluation and Management .pdfOsteoporosis - Definition , Evaluation and Management .pdf
Osteoporosis - Definition , Evaluation and Management .pdf
Jim Jacob Roy
 
Complementary feeding in infant IAP PROTOCOLS
Complementary feeding in infant IAP PROTOCOLSComplementary feeding in infant IAP PROTOCOLS
Complementary feeding in infant IAP PROTOCOLS
chiranthgowda16
 
Vestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptx
Vestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptxVestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptx
Vestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptx
Dr. Rabia Inam Gandapore
 
NARCOTICS- POLICY AND PROCEDURES FOR ITS USE
NARCOTICS- POLICY AND PROCEDURES FOR ITS USENARCOTICS- POLICY AND PROCEDURES FOR ITS USE
NARCOTICS- POLICY AND PROCEDURES FOR ITS USE
Dr. Ahana Haroon
 

Recently uploaded (20)

Adhd Medication Shortage Uk - trinexpharmacy.com
Adhd Medication Shortage Uk - trinexpharmacy.comAdhd Medication Shortage Uk - trinexpharmacy.com
Adhd Medication Shortage Uk - trinexpharmacy.com
 
CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1
CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1
CHEMOTHERAPY_RDP_CHAPTER 2 _LEPROSY.pdf1
 
Medical Quiz ( Online Quiz for API Meet 2024 ).pdf
Medical Quiz ( Online Quiz for API Meet 2024 ).pdfMedical Quiz ( Online Quiz for API Meet 2024 ).pdf
Medical Quiz ( Online Quiz for API Meet 2024 ).pdf
 
Clinic ^%[+27633867063*Abortion Pills For Sale In Tembisa Central
Clinic ^%[+27633867063*Abortion Pills For Sale In Tembisa CentralClinic ^%[+27633867063*Abortion Pills For Sale In Tembisa Central
Clinic ^%[+27633867063*Abortion Pills For Sale In Tembisa Central
 
Artificial Intelligence Symposium (THAIS)
Artificial Intelligence Symposium (THAIS)Artificial Intelligence Symposium (THAIS)
Artificial Intelligence Symposium (THAIS)
 
Cell Therapy Expansion and Challenges in Autoimmune Disease
Cell Therapy Expansion and Challenges in Autoimmune DiseaseCell Therapy Expansion and Challenges in Autoimmune Disease
Cell Therapy Expansion and Challenges in Autoimmune Disease
 
CHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdf
CHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdfCHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdf
CHEMOTHERAPY_RDP_CHAPTER 4_ANTI VIRAL DRUGS.pdf
 
Post-Menstrual Smell- When to Suspect Vaginitis.pptx
Post-Menstrual Smell- When to Suspect Vaginitis.pptxPost-Menstrual Smell- When to Suspect Vaginitis.pptx
Post-Menstrual Smell- When to Suspect Vaginitis.pptx
 
CHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdf
CHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdfCHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdf
CHEMOTHERAPY_RDP_CHAPTER 3_ANTIFUNGAL AGENT.pdf
 
Outbreak management including quarantine, isolation, contact.pptx
Outbreak management including quarantine, isolation, contact.pptxOutbreak management including quarantine, isolation, contact.pptx
Outbreak management including quarantine, isolation, contact.pptx
 
Ear and its clinical correlations By Dr. Rabia Inam Gandapore.pptx
Ear and its clinical correlations By Dr. Rabia Inam Gandapore.pptxEar and its clinical correlations By Dr. Rabia Inam Gandapore.pptx
Ear and its clinical correlations By Dr. Rabia Inam Gandapore.pptx
 
pathology MCQS introduction to pathology general pathology
pathology MCQS introduction to pathology general pathologypathology MCQS introduction to pathology general pathology
pathology MCQS introduction to pathology general pathology
 
8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx
8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx
8 Surprising Reasons To Meditate 40 Minutes A Day That Can Change Your Life.pptx
 
10 Benefits an EPCR Software should Bring to EMS Organizations
10 Benefits an EPCR Software should Bring to EMS Organizations   10 Benefits an EPCR Software should Bring to EMS Organizations
10 Benefits an EPCR Software should Bring to EMS Organizations
 
Ketone bodies and metabolism-biochemistry
Ketone bodies and metabolism-biochemistryKetone bodies and metabolism-biochemistry
Ketone bodies and metabolism-biochemistry
 
Cervical Disc Arthroplasty ORSI 2024.pptx
Cervical Disc Arthroplasty ORSI 2024.pptxCervical Disc Arthroplasty ORSI 2024.pptx
Cervical Disc Arthroplasty ORSI 2024.pptx
 
Osteoporosis - Definition , Evaluation and Management .pdf
Osteoporosis - Definition , Evaluation and Management .pdfOsteoporosis - Definition , Evaluation and Management .pdf
Osteoporosis - Definition , Evaluation and Management .pdf
 
Complementary feeding in infant IAP PROTOCOLS
Complementary feeding in infant IAP PROTOCOLSComplementary feeding in infant IAP PROTOCOLS
Complementary feeding in infant IAP PROTOCOLS
 
Vestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptx
Vestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptxVestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptx
Vestibulocochlear Nerve by Dr. Rabia Inam Gandapore.pptx
 
NARCOTICS- POLICY AND PROCEDURES FOR ITS USE
NARCOTICS- POLICY AND PROCEDURES FOR ITS USENARCOTICS- POLICY AND PROCEDURES FOR ITS USE
NARCOTICS- POLICY AND PROCEDURES FOR ITS USE
 

Sas tutorial 0524

  • 2. proc anova; class A B S; model y=S|A|B; test h=A e= S*A; run; The same as glm (但是比較沒用...)
  • 3. Example title 'Unbalanced Two-Way 2 1 28 . 23 34 42 13 Analysis of Variance'; 2 2 . 34 33 31 . 36 data a; 2 3 3 26 28 32 4 16 input drug disease @; 3 1 . . 1 29 . 19 do i=1 to 6; 3 2 . 11 9 7 1 -6 input y @; 3 3 21 1 . 9 3 . output; 4 1 24 . 9 22 -2 15 end; 4 2 27 12 12 -5 16 15 datalines; 4 3 22 7 25 5 12 . 1 1 42 44 36 13 19 22 ; 1 2 33 . 26 . 33 21 1 3 31 -3 . 25 25 24
  • 5. code ods graphics on; proc glm; class drug disease; model y=drug disease drug*disease /ss3; contrast 'drug 1 vs 2' drug 1 -1 0 0; contrast 'drug 1 vs 3' drug 1 0 -1 0; contrast 'drug 1 vs 4' drug 1 0 0 -1; lsmeans drug/ pdiff=all adjust=tukey; run; ods graphics off;
  • 8.
  • 9.
  • 10. Dummy variable • Category variable • Set reference group • Set N-1 d.variables: – 1 if xij belongs to the group specified – 0 if xij belongs to other groups • E.g. variable drug in the example: – 0 0 0 => drug=1 – 1 0 0 => drug=2 – 0 1 0 => drug=3 – 0 0 1 => drug=4
  • 11. Data
  • 12. Result (is the same)
  • 13. Why use d.v. coding? http://www.sas.com/offices/NA/canada/downloads/presen tations/VancouverMay11/Variable.pdf
  • 14.
  • 15. If you cannot run contrast analysis── • Check coefficients • Separate main effects and interactions into different models. • e.g. 2-way ANOVA with interaction: – model y = A B; (contrasts for main effects) – model y = A*B; (contrasts for interaction)