Global Management Presentation

The final project I have done for my global management class (MGT 865) in spring 2010. The project is talking about  how to  build a electric bicycle plant in other country. The software which I used in the video is called [...]

Read More

Gapminder

The Opera Class

It is a presentation for my honor class 308 Opera I compared the classical opera “Song to the moon ” and the traditional Chinese opera in the South of China called Legend of the White Snake. Both of them have [...]

Read More

Song to the Moon

The Wii Project

1. Wii Project 2008 The last Presentation for ELLI level 5 (ELLI stand for English Language as Second Language Institution in Eastern Kentucky University ) The topic is It is time to DIY, here is the Powerpoint I used for that [...]

Read More

Just do it

How to graph the five symmetric distributions in R

We want to graph the five symmetric distributions

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# display the five symmetric distributions
# These five symmetric distributions are Uniform(-sqrt(3)<x<sqrt(3)), 
# Nomal, Logistric, Double Expenential, Cauchy
 
x <- seq(-4,4,length=100)
hx <- dnorm(x) 
hx1 <- dunif(x,min=-sqrt(3),max=sqrt(3))
hx2 <- dlogis(x,location = 0, scale = 1)
hx3 <- dcauchy(x)
hx4 <- dlaplace(x)
par(mfrow = c(3,2))
plot(x,hx,type="l",main = "Normal Distribution",col="red")
plot(x,hx1,type='l',main = "Uniform distribution",col = "blue")
plot(x,hx2,type="l",main = "Logistic Distribution", col= "yellow")
plot(x,hx3,type="l",main = "Cauchy Distribution",col="green")
plot(x,hx4,type="l",main = "Double Exponential Distribution",col="black")

The result would be :

If We want to graph the five distributions in one plot, the code should be

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# display the five symmetric distributions in one plot
 
x <- seq(-4,4,length=100)
hx <- dnorm(x)
hx1 <- dunif(x,min=-sqrt(3),max=sqrt(3))
hx2 <- dlogis(x,location = 0, scale = 1)
hx3 <- dcauchy(x)
hx4 <- dlaplace(x)
labels <- c("Normal","Uniform","Logistic","Cauchy","Double Exponatial")
cols <- c("red","blue","yellow","green","black")
plot(x,hx4,type="l",main = "five Distributions",col=cols[5])
lines(x,hx,col=cols[1])
lines(x,hx1,col=cols[2])
lines(x,hx2,col=cols[3])
lines(x,hx3,col=cols[4])
legend("topright", inset=.05, title="Distributions",
    labels, lty=c(1, 1, 1, 1, 1), col=cols)

The result would be:

Share

Prepare for the SAS Advanced Test (Sample Code)

Creating and Managing Indexes Using PROC SQL

Sample Programs

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
/* 1.  Creating a Simple, Unique Index and a Composite Index */
 
     proc sql;
        create unique index EmpID
           on work.payrollmaster(empid);
        create index daily
           on work.marchflights(flightnumber,date);
     quit;
 
/*2. Displaying Index Specifications */
     proc sql;
        describe table marchflights;
     quit;
 
/*3. Determining Whether SAS is Using an Index */
 
     options msglevel=i;
     proc sql;
        select *
           from marchflights
           where flightnumber='182';
     quit;
 
/*4.Directing SAS to Ignore All Indexes */
 
     proc sql;
        select *
           from marchflights (idxwhere=no)
           where flightnumber='182';
     quit;
 
/*5.Directing SAS to Use a Specified Index */
 
     proc sql;
        select *
           from marchflights (idxname=daily)
           where flightnumber='182';
     quit;
 
/* 6. Dropping an Index */
 
     proc sql;
        drop index daily
           from work.marchflights;
     quit;
Share

Prepare for the SAS Advanced Test 1

I used to post some final projects and final presentation I did for my classes to this website. So the update of the website is kind of slow.

Now I would like to write more small articles which related my recently study path. For example, now I plan to study SAS for the SAS Advanced Test, I would take some notes or draw some flow charts which I thought are useful and post them to my site. I thought it would be a good way to push myself to study SAS every day and share with other people.

The book I study by myself is called SAS Macro language Course Notes by Jim Simon.

The summary is below:

  • Macro facility
  1. Def : a text processing facility for automating and customizing flexible SAS code
  2. Support : symbolic substitution, automated production, dynamic                    generation, conditional construction
  3. Enable to create and resolve macro variable; write and call macro program
  4. Adv: reduce program development time and reduce maintenance time.
  5. * It does not execute faster than SAS code
  6. * it depends on the efficiency of the underlying sas code
  • The process of SAS program are tokenized, compiled and executed.
  • A SAS program can be any combination of
  1. Data steps and Proc steps
  2. Global statement
  3. SAS component language(SCL)
  4. Structured Query Language(SQL)
  5. SAS macro Lanuage
  • Program Flow
  1. From Input Stack to word scanner then to the compiler
  2. Word scanner break the text into tokens
  3. Four types of Tokens are literal(inside of “” and ’’), number, name(begin with letter or underscore) and special
  4. Token ends when the beginning of another token or a blank after a token
  • %INCLUDE is a global SAS statement, not a macro language. It retrieve SAS source code from an external file and place it on the Input Stack.
  • Macro Triggers

%name-token : a macro statement, function or call.

&name-token: a macro variable reference.

  • Macro statement
  1. Begin with a % followed by a name token
  2. End with a :
  3. Represent macro trigger.
  4. Are executed by the macro processor
  • Option mprint symbolgen;
  1. Mprint: include all resolved macro variable reference.
  2. Symbolgen: track the resolution of macro variable.
  • Positional parameters: use one to one correspondence between parameter name and parameter value.
  • Keyword parameters: they are assigned a default or null value after an equal sign.
  • Mix parameter: positional parameter must be listed before keyword parameter.
Share

The Basic Graph in R(pairs plot)IV

1. Creating pairs plots

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Creating pairs plots
# a pairs plot is a very handy visualization for quickly scanning
# the correlations between many variables in a dataset.
 
#use the inbuild iris dataset, which gives the measurements in centimeter of the variables sepal length,
#sepal wideth, petal length and peteal width for 50 flowers from each of three speciees of iris
 
# The scatter plot in the first row and second column shows the relationship
# between Sepal length on the Y axis and Sepal Wideth on the X axis.
pairs (iris[,1:4],
main ="Relationhips between characteristics of iris flowers",
pch =19,
col ="blue",
cex = 0.9 )

The plot shows blow

2. Creating multiple plots

Read More

Share

The Basic Graph in R (Bar chart)III

1. Creating histograms and density plots

?Download download.txt
1
2
3
4
5
6
7
8
9
10
# creating histograms and density plots
# we pass rnorm()function as the variable, it generates a vector of 1,000 random
# numbers with a normal distribution.
# hist() function visualize the distribution of values.
c = rnorm(1000)
hist(c) 
# breaks = 3 can specify break points for the bins
 
#display probabilities instead of frequencies by density() function
lines(density(c),col='red')

The plot shows blow

2. Creating bar charts I

Read More

Share

The Basic Graph in R (Line & Pie charts) II

1.  Creating a line

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
# read import dataset by click or command line
#dailysales &lt;- read.csv("dailysales.csv")
plot(dailysales$units~as.Date(dailysales$date,"%d/%m/%y"),
type="b", #Specify type of plot as b for both line and point
main ="Unit Sales in the month of January 2010",
xlab ="Date",
ylab ="Number of units sold",
col = "blue")
 
lines(dailysales$units2~as.Date(dailysales$date, "%d/%m/%y"),
col = "red")

The plot shows below


2. Making better readable pie charts with clockwise-ordered

Read More

Share

The Basic Graph in R (Scatter plot) I

1. Creating scatter plots in R
and how to add linear regression line on a scatter plot

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Creating scatter plots
# Use one of R's inbuild datasets called cars to look at the relationship between
# the speed of cars and the distances taken to stop
 
# plot(x,y) or plot(y~x)
plot(cars$dist~cars$speed)
 
# adding linear regression line on a scatter plot
# fit a linear model to the data using lm(y~x) function and pass to lmfit
 
lmfit &lt;- lm(cars$dist~cars$speed)
 
# pass the linear fit to the abline()function to draw a line
abline(lmfit)
 
# fit a linear model to using simple.lm(x,y) and return the regression coefficients
# If your R version is before 2.12.2, you have to install a package called UsingR
# simple.lm(cars$speed,cars$dist)

The plot shows below

From Drop Box

2. Make the Scatter1 better

Read More

Share

Global Management Presentation

The final project I have done for my global management class (MGT 865) in spring 2010. The project is talking about  how to  build a electric bicycle plant in other country.

The software which I used in the video is called Gapminder(http://www.gapminder.org/)

 

Share