/* Jump to: Chapter 10 Table of Contents Chapter 12 */
/*
*/
/* Jump to: Next Section */
PROC SQL;
CREATE TABLE fifteens AS
SELECT name as FName LABEL='First Name',
sex,
age,
height FORMAT=6.1,
weight FORMAT=6.1
FROM sashelp.class
WHERE age=15
;
QUIT;
/* Jump to: Top of Section Top of Chapter */
/* Jump to: Next Section */
PROC SQL;
SELECT *
FROM fifteens
;
QUIT;
PROC PRINT DATA=fifteens LABEL NOOBS;
RUN;
PROC PRINT DATA=fifteens LABEL DOUBLE;
RUN;
PROC SQL DOUBLE NUMBER;
SELECT *
FROM fifteens
;
QUIT;
/* Jump to: Top of Section Top of Chapter */
/* Jump to: Next Section */
PROC PRINT DATA=fifteens N LABEL;
ID fname;
VAR sex;
RUN;
PROC SQL;
SELECT fname, sex
FROM fifteens
UNION ALL
SELECT '', ''
FROM fifteens(obs=1)
UNION ALL
SELECT 'N = ' || put(count(*),6. -L), ''
FROM fifteens
;
QUIT;
PROC MEANS DATA=fifteens MIN MEAN MAX MAXDEC=1;
VAR height weight;
RUN;
PROC SQL;
SELECT 'Height' LABEL = 'Variable',
MIN(height) LABEL = 'Minimum' FORMAT=12.1,
MEAN(height) LABEL = 'Mean' FORMAT=12.1,
MAX(height) LABEL = 'Maximum' FORMAT=12.1
FROM fifteens
UNION ALL
SELECT 'Weight',
MIN(weight),
MEAN(weight),
MAX(weight)
FROM fifteens
;
QUIT;
/* Jump to: Top of Section Top of Chapter */
/* Jump to: Next Section */
PROC SQL;
ALTER TABLE fifteens
ADD Comments CHAR(60),
Notes CHAR(60)
;
UPDATE fifteens
SET comments =
'William hopes to study at ' ||
'William and Mary, as does Mary.',
notes =
'That makes it hard to ' ||
'display a table compactly.'
WHERE fname='William'
;
UPDATE fifteens
SET comments =
'Mary, like William, aspires ' ||
'to attend William and Mary.',
notes =
'This is a second long text ' ||
' field in this table.'
WHERE fname='Mary'
;
QUIT;
OPTIONS LS=68;
PROC PRINT DATA=fifteens NOOBS;
ID fname;
VAR comments sex notes height weight;
RUN;
PROC SQL;
RESET DOUBLE
;
SELECT fname,
comments,
sex,
notes,
height,
weight
FROM fifteens
;
RESET NODOUBLE
;
QUIT;
PROC SQL;
RESET FLOW DOUBLE
;
SELECT fname,
comments,
sex,
notes,
height,
weight
FROM fifteens
;
RESET NOFLOW NODOUBLE
;
QUIT;
PROC REPORT DATA=fifteens NOWD;
COLUMN fname comments sex notes height weight;
DEFINE fname / GROUP ;
DEFINE comments / DISPLAY WIDTH=16 FLOW;
DEFINE sex / DISPLAY WIDTH=3 ;
DEFINE notes / DISPLAY WIDTH=16 FLOW;
DEFINE height / DISPLAY ;
DEFINE weight / DISPLAY ;
BREAK BEFORE fname / SKIP ;
RUN;
/* Jump to: Top of Section Top of Chapter */
/* Jump to: Next Section */
%let path=;
ODS LISTING CLOSE;
ODS HTML FILE="&path\htmldemo.html";
PROC PRINT DATA=fifteens LABEL NOOBS;
VAR fname comments sex notes height weight;
RUN;
ODS HTML CLOSE;
ODS LISTING;
PROC SQL;
ODS LISTING CLOSE;
ODS HTML FILE="&path\htmldemo.html";
SELECT fname,
comments,
sex,
notes,
height,
weight
FROM fifteens
;
ODS HTML CLOSE;
ODS LISTING;
QUIT;
/* Jump to: Top of Section Top of Chapter */