Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SP21 AEDE6120
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Angie Liu
SP21 AEDE6120
Commits
440ed855
Commit
440ed855
authored
4 years ago
by
Angie Liu
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
6af12db5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LabCode/lab_3.sas
+161
-0
161 additions, 0 deletions
LabCode/lab_3.sas
with
161 additions
and
0 deletions
LabCode/lab_3.sas
0 → 100644
+
161
−
0
View file @
440ed855
/* ----------------------------------------------------- */
/* AEDE 6120 */
/* Lab 3 */
* Importing data files from the repository;
* Making plots;
* SQL in SAS;
* Descriptive statistics;
* T-test of difference in means;
* Linear regression;
/* ----------------------------------------------------- */
* SP21 AEDE6120 repository;
* 'https://code.osu.edu/liu.6200/sp21-aede6120/-/tree/master/LabData' ;
* 'https://code.osu.edu/liu.6200/sp21-aede6120/-/tree/master/LabCode' ;
/* Importing data files from the repository */
* step1: set a filename for the data file;
filename
mydata
url
"https://code.osu.edu/liu.6200/sp21-aede6120/-/raw/master/LabData/wageEX.csv"
;
* step2: import the data file;
proc
import
file
=
mydata
out
=
work
.
wagedata
replace
dbms
=
csv
;
run
;
* step3: clear the filename;
filename
mydata
clear
;
/* Making plots */
*scatter plot;
proc
sgplot
data
=
sashelp
.
cars
;
scatter
x=
mpg_city
y=
horsepower
;
run
;
*line plot;
proc
sgplot
data
=
sashelp
.
cars
;
vline
mpg_city
/
response
=
horsepower
stat
=
mean
;
run
;
*line plot for time series;
*step 1: sort the data;
proc
sort
data
=
sashelp
.
stocks
out
=
stocks_sort
;
by
date
;
run
;
*step 2: make the plot;
proc
sgplot
data
=
stocks_sort
(
where
=
(
stock
=
'IBM'
));
series
x=
date
y=
close
;
run
;
*plot modification;
proc
sgplot
data
=
stocks_sort
(
where
=
(
stock
=
'IBM'
));
title
"IMB Closing Price 1986-2006"
;
series
x=
Date
y=
Close
/
markers
markerattrs
=
(
color
=
blue
symbol
=
'asterisk'
)
lineattrs
=
(
color
=
red
)
legendlabel
=
"IBM"
;
xaxis
grid
;
yaxis
label
=
"Closing Price"
;
reg
y=
close
x=
date
;
run
;
/* SQL in SAS */
* SELECT - columns (variables) that you want;
* FROM - tables (datasets) that you want;
* ON - join conditions that must be met;
* WHERE - row (observation) conditions that must be met;
* GROUP BY - summarize by these columns;
* HAVING - summary conditions that must be met;
* ORDER BY - sort by these columns;
*example 1;
proc
sql
;
create
table
sql_new
as
select
wage
,
female
,
educ
as
education
,
(
wage
)
**
2
as
wagesq
,
log
(
wage
)
as
lwage
from
wagedata
where
female
ne
0
order
by
educ
;
run
;
* = eq;
* >= ge;
* <= le;
* ~= ne;
*example 2;
proc
sql
;
create
table
sql_new
as
select
female
,
count
(
female
)
as
countn
from
wagedata
group
by
female
;
run
;
/* Descriptive statistics */
*simple descriptive statistics;
proc
means
data
=
wagedata
;
run
;
*simple descriptive stats by group;
*step 1: sort data by group;
proc
sort
data
=
wagedata
out
=
wagedata_sort
;
by
female
;
run
;
*step 2: generate descriptive stats;
proc
means
data
=
wagedata_sort
;
class
female
;
run
;
*more descriptive statistics;
proc
univariate
data
=
wagedata_sort
;
var
wage
;
*can add more variables;
by
female
;
*optional;
run
;
*correlations by group;
*step 1: sort data by group;
proc
sort
data
=
wagedata
;
by
female
;
run
;
*step 2: generate correlation;
proc
corr
data
=
wagedata
;
var
wage
educ
exper
;
by
female
;
run
;
/* T-test of difference in means */
ods
graphics
off
;
proc
ttest
data
=
wagedata
;
var
wage
educ
exper
;
class
female
;
run
;
/* Linear regression */
ods
graphics
off
;
proc
reg
data
=
wagedata
;
model
wage
=
educ
exper
married
;
output
out
=
ols
residual
=
resid
predicted
=
pred
;
run
;
quit
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment