Академический Документы
Профессиональный Документы
Культура Документы
Analyze
Access Explore Prepare and Export
data data data report results
on data
MEANS TITLE
LABEL
FOOTNOTE
FREQ
3
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Using Titles and Footnotes
4
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d. p105d01
5.01 Activity
Open p105a01.sas from the activities folder and perform the following tasks:
1. In the program, notice that there is a TITLE statement followed by two
procedures. Run the program. Where does the title appear in the output?
2. Add a TITLE2 statement above PROC MEANS to print a second line:
Summary Statistics for MaxWind and MinPressure
3. Add another TITLE2 statement above PROC FREQ with this title:
Frequency Report for Basin
4. Run the program. Which titles appear above each report?
5
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.01 Activity – Correct Answer
6
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.02 Activity
Open p105a02.sas from the activities folder. Notice that there are no TITLE
statements in the code. Run the program. Does the report have the same
titles assigned in the previous activity?
Yes
No
7
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.02 Activity – Correct Answer
Does the report have titles?
Some procedures automatically
add a procedure title.
Yes (SAS Enterprise Guide)
No (SAS Studio) SAS Studio
8
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Clearing Titles and Footnotes
9
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Using Macro Variables in Titles and Footnotes
%let age=13;
title;
footnote;
10
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Applying Temporary Labels to Columns
LABEL col-name="label-text";
11
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d. p105d01
Applying Temporary Labels to Columns
12
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Segmenting Reports
15
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.03 Activity
Open p105a03.sas from the activities folder and perform the following tasks:
1. Modify the LABEL statement in the DATA step to label the Invoice column
as Invoice Price.
2. Run the program. Why do the labels appear in the PROC MEANS report
but not in the PROC PRINT report? Fix the program and run it again.
16
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
continued...
5.03 Activity – Correct Answer
1. Modify the LABEL statement in the DATA step to label the Invoice column
as Invoice Price.
data cars_update;
set sashelp.cars;
keep Make Model MSRP Invoice AvgMPG;
AvgMPG=mean(MPG_Highway, MPG_City);
label MSRP="Manufacturer Suggested Retail Price"
AvgMPG="Average Miles per Gallon"
Invoice="Invoice Price";
run;
17
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.03 Activity – Correct Answer
2. Why do the labels appear in the PROC MEANS report but not in the PROC
PRINT report? Fix the program and run it again.
proc means data=cars_update min mean max;
var MSRP Invoice;
run; Most procedures
proc print data=cars_update label; automatically display
var Make Model MSRP Invoice AvgMPG; permanent labels,
run; but PROC PRINT still
needs the LABEL
option.
18
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Lesson 5: Analyzing and Reporting on Data
number of
unique values
change
statistics
graphs to view
distribution 20
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d. p105d01
Creating One-Way Frequency Reports and Graphs
21
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Creating Frequency Reports
and Graphs
This demonstration illustrates using statements
and options that are available in PROC FREQ to
customize frequency reports and graphs.
23
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.04 Activity – Correct Answer
Which statistics are included? Count and Percent
Which month has the highest number of storms?
September (With ORDER=FREQ, the highest count is listed first.)
24
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Creating Two-Way Frequency Reports
rows columns
25
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d. p105d03
Creating Two-Way Frequency
Reports
This demonstration illustrates creating a two-way
frequency report using PROC FREQ to customize the
results with options.
group
data
PROC MEANS
makes it easy to
summarize your
data in reports
or tables!
30
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Creating Summary Statistics Reports
32
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.05 Activity – Correct Answer
Which ocean had the lowest mean for minimum pressure? Pacific
Which season had the lowest mean for minimum pressure? 2015
33
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Creating an Output Summary Table
34
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.06 Activity
Open p105a06.sas from the activities folder and perform the following tasks:
1. Run the PROC MEANS step and compare the report and the wind_stats
table. Are the same statistics in the report and table? What do the first
five rows in the table represent?
2. Uncomment the WAYS statement. Delete the statistics listed in the PROC
MEANS statement and add the NOPRINT option. Run the program. Notice
that a report is not generated and the first five rows from the previous
table are excluded.
3. Add the following options in the OUTPUT statement and run the program
again. How many rows are in the output table?
output out=wind_stats mean=AvgWind max=MaxWind;
35
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
continued...
5.06 Activity – Correct Answer
1. Run the PROC MEANS step and compare the report and the wind_stats
table. Are the same statistics in the report and table? What do the first
five rows in the table represent?
The statistics are different. The first five rows in the table summarize the
entire input table.
36
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.06 Activity – Correct Answer
3. Add the following options in the OUTPUT statement and run the
program again. How many rows are in the output table?
Six rows, one for each value of BasinName.
View SAS
documentation for more
options to customize the
output table.
37
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5.07 Activity
Open p105a07.sas from the activities folder. Run the program and examine
the results to see examples of other procedures that analyze and report
on the data.
38
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Beyond SAS Programming 1
What if you want to ...
39
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
Practice
This practice reinforces the concepts
discussed previously.
41
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
1. If you run this program, which title or titles appear in the final
PROC PRINT results?
title1 'The First Line';
a. The Top Line title2 'The Second Line';
proc print data=sales;
b. The Top Line run;
The Next Line title2 'The Next Line';
c. The Top Line proc print data=sales;
The Second Line run;
title 'The Top Line';
d. The Top Line proc print data=sales;
The First Line run;
The Next Line
42
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
1. If you run this program, which title or titles appear in the final
PROC PRINT results?
title1 'The First Line';
a. The Top Line title2 'The Second Line';
proc print data=sales;
b. The Top Line run;
The Next Line title2 'The Next Line';
c. The Top Line proc print data=sales;
The Second Line run;
title 'The Top Line';
d. The Top Line proc print data=sales;
The First Line run;
The Next Line
43
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
2. Which statement substitutes the value of the macro variable Year
in the footnote?
%let Year=2018;
44
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
2. Which statement substitutes the value of the macro variable Year
in the footnote?
%let Year=2018;
45
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
3. Which statement is true based on the given program?
46
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
3. Which statement is true based on the given program?
47
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
4. Which statement is true regarding a BY statement in a reporting procedure
such as PROC PRINT?
48
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
4. Which statement is true regarding a BY statement in a reporting procedure
such as PROC PRINT?
49
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5. Which statement is false concerning the FREQ procedure?
50
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
5. Which statement is false concerning the FREQ procedure?
51
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
6. Which PROC FREQ step creates the results shown here?
a. b.
c. d.
54
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
7. Which report is created from the following PROC FREQ step?
proc freq data=sashelp.cars;
where Cylinders in (4,6) and Type in ('Sedan','SUV');
tables Type*Cylinders / nocol norow crosslist;
run;
a. b.
c. d.
55
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
8. Which statement is true concerning the MEANS procedure?
56
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
8. Which statement is true concerning the MEANS procedure?
57
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
9. The input table must be pre-sorted by the columns listed
in the CLASS statement of a PROC MEANS step.
58
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
9. The input table must be pre-sorted by the columns listed
in the CLASS statement of a PROC MEANS step.
59
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
10. Which statement from PROC MEANS contains valid syntax
for creating a summary output table?
a. out=work.summary mean;
b. out work.summary mean(Weight)=TotW;
c. output out work.summary Weight=TotW;
d. output out=work.summary mean(Weight)=TotW;
60
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.
10. Which statement from PROC MEANS contains valid syntax
for creating a summary output table?
a. out=work.summary mean;
b. out work.summary mean(Weight)=TotW;
c. output out work.summary Weight=TotW;
d. output out=work.summary mean(Weight)=TotW;
61
Copy rig ht © SA S Institute Inc. A ll rig hts re se rve d.