/* Chapter 7: Global Statements, Options, and Session Management */

/* Jump to: Chapter 6    Table of Contents    Chapter 8 */

/*

*/

/* Chapter 7: Introductory Section */

/* Jump to: Next Section */

PROC SQL;                                                                       
CREATE TABLE twelves AS                                                         
SELECT       name as FName,                                                     
             sex,                                                               
             height,                                                            
             weight                                                             
FROM         sashelp.class                                                      
WHERE        age=12                                                             
;                                                                               
QUIT;                                                                           

/* Jump to: Top of Section     Top of Chapter */

/* 7.1: Global Statements */

/* Jump to: Next Section */

PROC TABULATE DATA=twelves NOSEPS;                                              
CLASS sex;                                                                      
VAR height weight;                                                              
                                                                                
TITLE 'Weight Minima by Sex';                                                   
TABLE sex, weight * MIN * F=7.1;                                                
                                                                                
TITLE 'Height Maxima by Sex';                                                   
TABLE sex, height * MAX * F=7.1;                                                
                                                                                
RUN;                                                                            
                                                                                
TITLE 'Weight Minima by Sex';                                                   
TITLE 'Height Maxima by Sex';                                                   
                                                                                
PROC TABULATE DATA=twelves NOSEPS;                                              
CLASS sex;                                                                      
VAR height weight;                                                              
                                                                                
TABLE sex, weight * MIN * F=7.1;                                                
                                                                                
TABLE sex, height * MAX * F=7.1;                                                
                                                                                
RUN;                                                                            
                                                                                
TITLE 'Weight Minima by Sex';                                                   
PROC TABULATE DATA=twelves NOSEPS;                                              
CLASS sex;                                                                      
VAR height weight;                                                              
TABLE sex, weight * MIN * F=7.1;                                                
RUN;                                                                            
                                                                                
TITLE 'Height Maxima by Sex';                                                   
PROC TABULATE DATA=twelves NOSEPS;                                              
CLASS sex;                                                                      
VAR height weight;                                                              
TABLE sex, height * MAX * F=7.1;                                                
RUN;                                                                            
                                                                                
PROC SQL;                                                                       
                                                                                
TITLE 'Weight Minima by Sex';                                                   
SELECT       sex,                                                               
             MIN(weight) FORMAT=7.1 LABEL='Weight Min'                          
FROM         twelves                                                            
GROUP BY     sex                                                                
;                                                                               
                                                                                
TITLE 'Height Maxima by Sex';                                                   
SELECT       sex,                                                               
             MAX(height) FORMAT=7.1 LABEL='Height Max'                          
FROM         twelves                                                            
GROUP BY     sex                                                                
;                                                                               
                                                                                
TITLE;                                                                          
                                                                                
QUIT;                                                                           
                                                                                

/* Jump to: Top of Section     Top of Chapter */

/* 7.2: PROC SQL Options */

/* Jump to: Next Section */

PROC SQL     FEEDBACK STIMER;                                                   
SELECT       *                                                                  
FROM         twelves                                                            
ORDER BY     height                                                             
;                                                                               
                                                                                
PROC SQL     FEEDBACK OUTOBS=3;                                                 
                                                                                
PROC SQL     FEEDBACK STIMER;                                                   
                                                                                
SELECT       *                                                                  
FROM         twelves                                                            
ORDER BY     height                                                             
;                                                                               
RESET        NOSTIMER OUTOBS=3;                                                 
SELECT       *                                                                  
FROM         twelves                                                            
ORDER BY     height                                                             
;                                                                               
                                                                                
QUIT;                                                                           
                                                                                
PROC SQL     FEEDBACK;                                                          
                                                                                
RESET        STIMER;                                                            
SELECT       *                                                                  
FROM         twelves                                                            
ORDER BY     height                                                             
;                                                                               
RESET        NOSTIMER;                                                          
                                                                                
RESET        OUTOBS=3;                                                          
SELECT       *                                                                  
FROM         twelves                                                            
ORDER BY     height                                                             
;                                                                               
RESET        OUTOBS=MAX;                                                        
                                                                                
QUIT;                                                                           

/* Jump to: Top of Section     Top of Chapter */