Uploaded by schueler_cc

Computer-Aided Analysis Lecture 1

advertisement
Review
SAS windows
-. Program editor, Log, Output windows and Exploring window by default.
-. Program window is a notepad you can write the code in it.
-. Log window shows the processing results when running the code.
-. Output window is the window containing all the output for your commands.
1
Review
SAS windows
-. You can check your windows
2
1
Review
Understanding library
-. Library is a function to connect the external files to SAS.
-. Library has two types
-. Without assigning any library, ‘Work’ (temporary) library is default.
3
Review
Set up a library
-. If you want to save SAS files, you need to create your own library.
4
2
Review
Set-up library
-. You can put the library name in the blank on the first row (1), and then choose the
physical location by clicking “search” (2), then click “OK” (3).
1
2
3
5
Review
Data importing
-. If you have to use external files such as excel, csv, and txt file, you have to import
them to SAS at first by clicking “Import”.
6
3
Review
Data importing
-. Next, you will see the wizard. After choosing the data type, and click “Next”.
7
Review
Data importing
-. Then, choose the file you will import by clicking “Browse”.
1
2
3
8
4
Review
Data importing
-. Before your click the “next” button, choose ‘option’ right.
9
Review
Data importing
-. Then, choose the library you will put your imported data in.
10
5
Review
Data importing
-. Then put the (SAS) file name in the blank after “Member”.
11
Review
Data importing
-. Then click “Finish” button.
12
6
Review
Practice
-. Create the library called ‘bids204’.
-. Go to blackboard, and download ‘ex1.csv’ file and import it to the ‘bids204’
with a file name of ‘ex1’.
13
Review
Practice
14
7
Review
Basic commands
-. We can delete or select some variables.
DATA EX1;
SET BIDS.EX1;
KEEP VAR1 VAR3;
DROP VAR2 VAR4;
RUN;
-. KEEP commands: the variables are selected in the new dataset
-. DROP commands: the variables are dropped in the new dataset
15
Review
Editing dataset
-. We can rename the variable.
DATA EX1;
SET BIDS.EX1;
RENAME OLDNAME = NEWNAME;
RUN;
-. RENAME commands: OLDNAME is renamed to NEWNAME
16
8
Review
Editing dataset
-. We can create a new variable.
DATA EX1;
SET BIDS.EX1;
varNAME = VAR1 +VAR2;
RUN;
-. varNAME is newly created by summing the existing two variables,
VAR1, VAR2
17
Review
Sorting dataset
-. Data can be sorted in ascending or descending order.
PROC SORT DATA=BIDS.EX1;
BY (DESCENDING) VAR1;
RUN;
-. BY commands: data set is sorted by the variable after BY.
-. Without DESCENDING option, the data set is sorted in ascending order.
18
9
Homework1
Write your SAS codes and upload the code file to Blackboard.
-. (1) Select Name, Sex, Age, Height and Weight from ex1 dataset.
-. (2) Change the variable name of ‘Sex’ to ‘Gender’.
-. (3) Sort the dataset by ‘Age’ in ascending order and save the sorted dataset
to ‘exercise1’.
19
10
Download