/********************** kars.sas **************************/ title 'Metric Cars Data Example'; title2 'Jerry Brunner: Student Number 999999999'; data auto; infile '/folders/myfolders/431s17/mcars4.data.txt' firstobs=2 ; /* Skipping the header on line 1 */ input id country $ lper100k weight length; mpg = 100/lper100k * 0.6214/0.2642; /* Indicator dummy vars: Ref category is Japanese */ if country = 'US' then c1=1; else if country = 'Japan' then c1=0; else if country = 'Europ' then c1=0; if country = 'Europ' then c2=1; else if country = 'US' then c2=0; else if country = 'Japan' then c2=0; /* Product terms for the interactions */ wc1 = weight*c1; wc2 = weight*c2; Lc1 = length*c1; Lc2 = length*c2; label country = 'Country of Origin' lper100k = 'Litres per 100 Kilometers' weight = 'Weight in kg' length = 'Length in cm' mpg = 'Miles per gallon'; proc freq; title3 'Frequency Distributions'; tables country c1 c2 ; proc means; title3 'Means and standard deviations by country'; class country; var lper100k mpg weight length; proc corr; title3 'Correlation matrix'; var lper100k mpg weight length; ods graphics off; /* Suppress diagnostic plots */ proc reg; title3 'Regression model with non-parallel planes'; model lper100k = weight length c1 c2 wc1 wc2 Lc1 Lc2; EqualSlopes: test wc1 = wc2 = Lc1 = Lc2 = 0; proc reg; title3 'Parallel planes'; model lper100k = weight length c1 c2; USvsEURO: test c1=c2; /* US vs European controlling for weight and length */ country: test c1 = c2 = 0;