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
24adb7a2
Commit
24adb7a2
authored
4 years ago
by
Angie Liu
Browse files
Options
Downloads
Patches
Plain Diff
Delete lab_2.sas
parent
c923fb18
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
lab_2.sas
+0
-122
0 additions, 122 deletions
lab_2.sas
with
0 additions
and
122 deletions
lab_2.sas
deleted
100644 → 0
+
0
−
122
View file @
c923fb18
/* ----------------------------------------------------- */
/* AEDE 6120 */
/* Lab 2 SAS Basics */
* A few things to notice:
- remember to put a semicolon after your command
- remember to put a RUN after your step
- case and format of the code do not matter
- two ways to add comments;
* lab preparation:
- create the 'aede' folder
- upload 'CLASS1.csv' and 'CLASS2.xlsx'
- create a sas program;
/* ----------------------------------------------------- */
/* Set library path */
libname
aede
"/home/u49260161/aede"
;
/* Import data files */
* example 1: import a csv file as a sas table;
PROC
IMPORT
DATAFILE
=
"/home/u49260161/aede/CLASS1.csv"
DBMS
=
csv
OUT
=
aede
.
class1
;
GETNAMES
=
yes
;
RUN
;
* example 2: import a xlsx file as a sas table;
PROC
IMPORT
DATAFILE
=
"/home/u49260161/aede/CLASS2.xlsx"
DBMS
=
xlsx
OUT
=
aede
.
class2
;
GETNAMES
=
yes
;
RUN
;
/* Print datasets */
PROC
PRINT
DATA
=
aede
.
class1
;
RUN
;
/* Export data files */
* export a sas table as a xlsx file;
PROC
EXPORT
DATA
=
aede
.
class1
OUTFILE
=
"/home/u49260161/aede/class1x.xlsx"
DBMS
=
xlsx
REPLACE
;
RUN
;
/* Access SAS tables */
DATA
work.class1
;
SET
aede
.
class1
;
RUN
;
/* Filter rows & select columns */
DATA
work.class1filt
;
SET
aede
.
class1
;
WHERE
age
>=
13
AND
sex
=
'F'
;
RUN
;
DATA
work.class1keep
;
SET
aede
.
class1
;
KEEP
name
sex
age
;
RUN
;
DATA
work.class1drop
;
SET
aede
.
class1
;
DROP
sex
age
;
RUN
;
/* Create new variables */
DATA
work.class1newv
;
SET
aede
.
class1
;
new_height
=
height
*
2
-
50
;
new_weight
=
weight
+
20
;
RUN
;
/* Sort */
PROC
SORT
DATA
=
aede
.
CLASS1
OUT
=
work
.
class1s
;
BY
age
name
;
RUN
;
PROC
SORT
DATA
=
aede
.
CLASS1
OUT
=
work
.
class1s
;
BY
age
descending
height
;
RUN
;
/* Merge */
PROC
SORT
DATA
=
aede
.
CLASS1
OUT
=
work
.
sort1
;
BY
Name
;
RUN
;
PROC
SORT
DATA
=
aede
.
CLASS2
OUT
=
work
.
sort2
;
BY
Name
;
RUN
;
DATA
aede.class_merge
;
MERGE
sort1
sort2
;
*note: 'work' is optional;
BY
Name
;
RUN
;
/* Delete */
PROC
DELETE
DATA
=
sort1
sort2
;
RUN
;
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