*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

dm "output;clear;log;clear";

 

Libname ia "C:\_SasCourse2006\Course1\SAS_Data"

/*    c09s2d1       */

proc freq data=ia.crew;

   tables JobCode;

   title 'Distribution of Job Code Values';

run;

 

/*    c09s2d1a       */

proc freq data=ia.crew nlevels;

   tables JobCode Location;

   title 'Distribution of Job Code and Location Values';

run;

 

/*     c09s2d1b       */

proc freq data=ia.crew nlevels;

   tables JobCode Location / noprint;

   title 'Number of Levels for Job Code and Location';

run;

 

proc freq data=ia.crew nlevels;

   tables _all_ / noprint;

   title 'Number of Levels for All Variables';

run;

 

*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

/*    c09s2d2         */

proc format;

   value $codefmt

         'FLTAT1'-'FLTAT3'='Flight Attendant'

         'PILOT1'-'PILOT3'='Pilot';

run;

 

proc freq data=ia.crew;

   format JobCode $codefmt.;

   tables JobCode;

run;

 

/*   c09s2d3          */

proc format;

   value $codefmt

         'FLTAT1'-'FLTAT3'='Flight Attendant'

         'PILOT1'-'PILOT3'='Pilot';

   value money

         low-<25000 ='Less than 25,000'

         25000-50000='25,000 to 50,000'

         50000<-high='More than 50,000';

run;

 

proc freq data=ia.crew;

   tables JobCode*Salary;

   format JobCode $codefmt. Salary money.;

   title 'Salary Distribution by Job Codes';

run;

 

/*    c09s2d3a         */

proc freq data=ia.crew;

   tables JobCode*Location / crosslist;

   title 'Location Distribution for Job Codes';

run;

 

*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

/*   c09s2d4            */

proc means data=ia.crew;

   title 'Salary Analysis';

run;

 

/*   c09s2d5            */

proc means data=ia.crew;

   var Salary;

   title 'Salary Analysis';

run;

 

/*      c09s2d6         */

proc means data=ia.crew maxdec=2;

   var Salary;

   class JobCode;

   title 'Salary by Job Code';

run;

 

*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

*** c09s2d2.sas ***;

/*    c09s2d2         */

proc format;

   value $codefmt

         'FLTAT1'-'FLTAT3'='Flight Attendant'

         'PILOT1'-'PILOT3'='Pilot';

run;

proc freq data=ia.crew;

   format JobCode $codefmt.;

   tables JobCode;

run;

 

 

 

 


*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

dm "output;clear;log;clear";

Libname ia "C:\_SasCourse2006\Course1\SAS_Data"

 

/*     c09s3d1               */

title 'Salary Analysis';

proc report data=ia.crew nowd;

   column JobCode Location Salary;

run;

 

/*     c09s3d2               */

proc report data=ia.crew nowd;

   column JobCode Location Salary;;

   define JobCode / width=8 'Job Code';

   define Location / 'Home Base';

   define Salary / format=dollar10.;

run;

 

/*     c09s3d3               */

proc report data=ia.crew nowd;

   column JobCode Location Salary;;

   define JobCode / order width=8 'Job Code';

   define Location / 'Home Base';

   define Salary / format=dollar10.;

run;

 

/*     c09s3d4               */

proc report data=ia.crew nowd;

   column JobCode Location Salary;;

   define JobCode / group width=8 'Job Code';

   define Location / group 'Home Base';

   define Salary / format=dollar10.;

run;

 

/*     c09s3d5               */

proc report data=ia.crew nowd;

   column JobCode Location Salary;

   define JobCode / group width=8 'Job Code';

   define Location / group 'Home Base';

   define Salary / format=dollar10.;

   rbreak after / summarize dol;

run;

 

/*      c09s3d6              */

proc report data=ia.crew nowd headline headskip;

   column JobCode Location Salary;

   define JobCode / group width=8 'Job Code';

   define Location / group 'Home Base';

   define Salary / format=dollar10.;

   rbreak after / summarize dol;

run;

 

*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

dm "output;clear;log;clear";

 

Libname ia "C:\_SasCourse2006\Course1\SAS_Data";

 

/*     c09s4d1            */

title 'Flight Attendant Counts by Location';

proc tabulate data=ia.fltat;

   class Location ;

   table Location;

run;

 

/*     c09s4d2           */

proc tabulate data=ia.fltat;

   class Location ;

   table Location all;

run;

 

/*     c09s4d3           */

title2 'by JobCode';

proc tabulate data=ia.fltat;

   class Location JobCode;

   table JobCode, Location;

run;

 

/*     c09s4d4           */

title 'Counts for Cary and Frankfurt';

proc tabulate data=ia.fltat;

   where Location in ('CARY', 'FRANKFURT');

   class Location JobCode;

   table JobCode, Location;

run;

 

/*     c09s4d5           */

proc tabulate data=ia.fltat;

   where Location in ('CARY', 'FRANKFURT');

   class Location JobCode;

   table JobCode all, Location all;

run;

 

/*     c09s4d6           */

title 'Total Salary for Cary and Frankfurt';

proc tabulate data=ia.fltat;

   where Location in ('CARY', 'FRANKFURT');

   class Location JobCode;

   var Salary;

   table JobCode, Location*Salary;

run;

 

/*        c09s4d7         */

proc tabulate data=ia.fltat format=dollar12.;

   where Location in ('CARY', 'FRANKFURT');

   class Location JobCode;

   var Salary;

   table JobCode, Location*Salary;

run;

 

/*        c09s4d8            */

title 'Average Salary for Cary and Frankfurt';

proc tabulate data=ia.fltat format=dollar12.;

   where Location in ('CARY', 'FRANKFURT');

   class Location JobCode;

   var Salary;

   table JobCode, Location*Salary*mean;

run;

 

/*        c09s4d9            */

proc tabulate data=ia.fltat format=dollar12.;

   where Location in ('CARY', 'FRANKFURT');

   class Location JobCode;

   var Salary;

   table JobCode all, Location*Salary*mean all*Salary*mean;

run;

 

 

 

*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

dm "output;clear;log;clear";

 

Libname ia "C:\_SasCourse2006\Course1\SAS_Data"

 

/*        c10s1d1            */

proc gchart data=ia.crew;

   vbar JobCode;

run;

 

/*        c10s1d2            */

proc gchart data=ia.crew;

   hbar JobCode;

run;

 

/*        c10s1d3            */

proc gchart data=ia.crew;

   pie JobCode;

run;

 

/*        c10s1d4            */

proc gchart data=ia.crew;

   vbar Salary;

run;

 

/*        c10s1d5            */

proc gchart data=ia.crew;

   vbar Salary / discrete;

run;

 

/*        c10s1d6                      */

proc gchart data=ia.crew;

   vbar JobCode / sumvar=Salary type=mean;

run;

 

/*            c10s1d7                      */

proc gchart data=ia.crew;

   pie JobCode / sumvar=Salary type=sum;

   format Salary dollar8.;

run;

   pie JobCode / sumvar=Salary type=sum

                 fill=x;

   format Salary dollar8.;

run;

   pie JobCode / sumvar=Salary type=sum

                 fill=x explode='PILOT3';

   format Salary dollar8.;

run;

quit;

 

 

*---+----1----+----2----+----3----+----4----+----5----+----6----+---;

dm "output;clear;log;clear";

 

Libname ia "C:\_SasCourse2006\Course1\SAS_Data"

 

proc gplot data=ia.flight114;

   where date between '02mar2001'd and '08mar2001'd;

   plot Boarded*Date;

   title 'Total Passengers for Flight 114';

   title2 'between 02Mar2001 and 08Mar2001';

run;

   plot Boarded*Date;

   symbol value=square i=join;

run;

   plot Boarded*Date;

   symbol c=red w=2;

run;

   plot Boarded*Date / vaxis=100 to 200 by 25 ctext=blue;

run;

   plot Boarded*Date / vaxis=100 to 200 by 25 ctext=blue;

   label Boarded='Passengers Boarded'

         Date='Departure Date';

run;

quit;