lab2_exercises

docx

School

University of Southern California *

*We aren’t endorsed by this school

Course

MISC

Subject

Statistics

Date

Apr 3, 2024

Type

docx

Pages

8

Uploaded by MegaElkPerson49

Report
hLab #2 Exercises  Use the subjdata.sas7bdat dataset located in the Lab Datasets folder in Canvas. Please provide all relevant code and output to receive full credit for the lab.  libname subject "Z:\OneDrive\Documents\sas\" ; data subject.subjdata; set subject.subjdata; run ; proc contents data = subject.subjdata; run ; proc format ; value sexf 1 = "male" 2 = "female" ; value yesnof 0 = "no" 1 = "yes" ; value racef 1 = "asian" 2 = "african" 3 = "hispanic" 4 = "nonhispanic white" 5 = "other" ; run ; libname subject "Z:\OneDrive\Documents\sas\" ; data subject.subjdata; set subject.subjdata; format sex sexf. race racef. birthdat mmddyy8. testdat mmddyy8. yesno yesnof. ; run ; Graphics 1. Write an SGPLOT program to overlay both a histogram and density plot of FEV on one graph. (Label the X- and Y- axis descriptively, as if ready for journal publication). proc sgplot data = subject.subjdata; title "Histogram and Density Plot of Forced Expiratory Volume(FEV)" ; histogram fev; xaxis label = "FEV" ; yaxis label = "Percentage observed" ; density fev; keylegend / location =inside position =topright across = 1 noborder ; run ;
2. Regress MMEF on htinches and output residuals and predicted values proc reg data = subject.subjdata; model MMEF=htinches; output out = subject r =resid p =pred; run ;
1. Write a SGPLOT program to overlay both a histogram and density plot of the residuals on one graph. proc sgplot data = subject.subjdata; title "Histogram and Density Plot of Maximal Mid-Expiratory Flow (MMEF) on Height in Inches(htinches)" ; histogram MMEF; xaxis label = "Residuals" ;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
yaxis label = "Percentage observed" ; density MMEF; keylegend / location =inside position =topright across = 1 noborder ; run ; 2. Write another SGPLOT program to determine your linearity assumption (use the loess instead of the scatter option). Add a reference line at y = 0. proc sgplot data = subject.subjdata; title "Loess of Maximal Mid-Expiratory Flow (MMEF) on Height in Inches(htinches)" ; loess x =htinches y =mmef; refline 0 ; keylegend / location =inside position =topright across = 1 noborder ; run ;
3. Write a SGPLOT program to graph a horizontal bar chart of asthma, stacked by categories of gender proc sgplot data =subject.subjdata; hbar asthma/ group =sex groupdisplay =stack; title 'Asthma stacked by Gender' ; run ; 4. Augment this program to show panels of doctor diagnosed asthma by city, also stacked by gender ( hint : use SGPANEL – see section 8.11 in The Little SAS Book, 6 th edition) proc sgpanel data =subject.subjdata; panelby townname; hbar asthma / group =sex groupdisplay =stack; title "Asthma by Gender/City" ; run ;
5. Write an SGPLOT program to graph both a scatter and regression line of MMEF on HTINCHES. Change the labels of the X- and Y-Axis to be descriptive. Also plot the confidence limits of the prediction and of the mean values (HINT: Use the cli/clm options similar to proc reg) proc sgplot data = subject.subjdata; title "Density Plot of Maximal Mid-Expiratory Flow (MMEF)on Height in Inches (Htinches)ScatterPlot" ; scatter x =htinches y =mmef; reg x =htinches y =mmef /cli clm; xaxis label = "Height in Inches" ; yaxis label = "MMEF(maximal mid-expiratory flow)" ; keylegend / location =inside position =topright across = 1 noborder ; run ;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
6. Write an SGPANEL program to graph box plots of FEV by those who have pets vs. those who do not proc sgpanel data = subject.subjdata; title "Forced Expiratory Volume(FEV) by Pets" ; panelby pets; vbox fev; run ; 7. Write an SGPLOT program to graph bar charts of the mean values of FEV and FVC on one plot by asthma status (HINT: try changing the transparency and bar width of one variable to display both on one graph). proc sgplot data = subject.subjdata; title "FEV and FVC Bar Graph by Asthma Mean" ;
vbar asthma/ response =fev stat =mean group =asthma; vbar asthma/ response =fev stat =mean group =asthma transparency = 0.6 barwidth = 0.6 ; keylegend / location =outside position =topmright across = 1 noborder ; run ;