Friday, 2 October 2015

In this post we are discussing about the following topics
Summarizing data
Counting frequencies
Creating tabular reports
Output delivery systems
Generating high quality graphics

Chapter- 16 summarizing the data:

In this chapter we will learn how to summarize data with the help of procedure called proc means and its various functions like by, class, _TYPE_ etc.

Lets solve few problems in these chapters.

Question:
We have data of college students, now we have to find number of students, how many students data is missing, minimum value of each variable, maximum, median for two variables mainly ClassRank and GPA using BY function and Class function.

Code:
proc sort data=a15017.collegedata;
    var gender schoolsize;

 proc means data=a15017.college n nmiss min max mean median maxdec=2;
    by gender schoolsize;
run;

proc means data=a15017.college n nmiss min max mean median maxdec=2;
    class gender schoolsize;
run;
I have created a permanent library named as A15017

Output:

                                         
 
                                                

Explanation:

The first proc step of this code will sort the data according to gender and school size. Second and third proc steps are two different ways to summarize data one is by ‘BY’ function and second is by ‘Class’ function. The respective outputs are pasted below.

 Learning:
In this chapter i have learnt about summarizing by using Proc Means.

Chapter 17 Counting Frequencies:

Question:
Use a user-defined format to group ages into three categories: 40 and younger, 41 to
60, and 61 and older. Use the appropriate options to omit the cumulative statistics
and percentages.

Explanation:
In this problem we have to calculate the frequencies of age which is divided in to 3 categories. Young, Mediun and old.

This dividing is achieved using proc format statement which I have already discussed in my previous blog.

After this division is done we use proc freq statement which is used to calculate the frequencies of a variable.

As we use class statement in proc means here we use tables statement.


In table statement we have given a variable for which we need to calculate frequency. After that we have given / no cum no percent . This means that I need only frequnecy values and no percentage and no cumulative values. As I have already discussed after every proc statement we end with run;

Explanation:

We have learned procedure proc freq in this chapter and its functions. learned how to create single table, two way table and three way tables which was our program in this chapter.

Learning:
In this chapter i have learnt about the Proc freq

Chapter 18 Creating Tabular reports:
In this chapter we are going to learn about Procedure called PROC TABULATE and its functions.


Lets take a task from Ron Cody to create a table and calculate the row percentages of the respective table

Code:
title "Counts and Percentages";

proc tabulate data=a15017.college noseps;
    class Scholarship Gender;
    table
 (Gender ALL)*(n*f=5. pctn*f=pctfmt7.1) , (Scholarship ALL);
    keylabel ALL='All' pctn='Percent';

run;

Output:



Learning:

In this chapter we have learned how to use procedure proc tabulate and its functions and various options.

Chapter-19: Output Delivery Systems

In this chapter we will learn how to save our output in html format. We will use functions like ods html etc.

Lets take an example and understand this further.

As we are working with college data set. Lets continue with it. Now our task is to write our output into a html file.

Code:
ods listing close;
ods html file='/folders/myfolders/Assignment/prob19_1.html' style=journal;
title "Sending Output to an HTML File";

proc print data=a15017.college(obs=8) noobs;
run;

proc means data=a15004.college n mean maxdec=2;
    var GPA ClassRank;
run;

ods html close;
ods listing;


Output:


Learning:
We have learned how to store our output as a html file in this chapter and most importantly we learned how to use various functions of odc html functions along with other procedures like proc means in this case.

Chapter-20: Generating High quality graphics

Question:
/*Using the SAS data set Fitness, produce a scatter plot showing the time to run a mile
(TimeMile) on the y-axis and the resting pulse (RestPulse) on the x-axis. Use the dot
as the plotting symbol.*/

Code:
data a15017.chart8;
set learn.fitness;
run;
symbol value=dot;
proc gplot data=a15020.chart8;
plot timemile*maxpulse ;
run;
quit;

Output:


Explanation:


We use proc gplot for creating charts and next we give variables in plot statement.

Learning:
In this chapter i have learnt how to deal with charts 



















No comments:

Post a Comment