Скачать презентацию Today Run SAS programs on Saturn UNIX Скачать презентацию Today Run SAS programs on Saturn UNIX

e8d912073f882e1e02ee0b808b7f1ad7.ppt

  • Количество слайдов: 26

Today: • Run SAS programs on Saturn (UNIX tutorial) • Runs SAS programs on Today: • Run SAS programs on Saturn (UNIX tutorial) • Runs SAS programs on the PC

Raw Data Read in Data Process Data (Create new variables) Data Step Output Data Raw Data Read in Data Process Data (Create new variables) Data Step Output Data (Create SAS Dataset) Analyze Data Using Statistical Procedures PROCs

* This is a short example program to demonstrate what a SAS program looks * This is a short example program to demonstrate what a SAS program looks like. This is a comment statement because it begins with a * and ends with a semi-colon ; DATA demo; INPUT gender $ age marstat $ credits state $ ; if credits > 12 then fulltime = 'Y'; else fulltime = 'N'; if state = 'MN' then resid = 'Y'; else resid = 'N'; DATALINES; F 23 S 15 MN F 21 S 15 WI F 22 S 09 MN F 35 M 02 MN F 22 M 13 MN F 25 S 13 WI M 20 S 13 MN M 26 M 15 WI M 27 S 05 MN M 23 S 14 IA M 21 S 14 MN M 29 M 15 MN ; RUN; TITLE 'Running the Example Program'; PROC PRINT DATA=DEMO ; VAR gender age marstat credits fulltime state ; RUN;

1 DATA demo; Create a SAS dataset called demo 2 INPUT gender $ What 1 DATA demo; Create a SAS dataset called demo 2 INPUT gender $ What are the variables age marstat $ credits state $ ; 3 if credits > 12 then fulltime = 'Y'; else fulltime = 'N'; 4 if state = 'MN' then resid = 'Y'; else resid = 'N'; Statements 3 and 4 create 2 new variables

5 F F F M M M ; DATALINES; 23 S 15 MN 21 5 F F F M M M ; DATALINES; 23 S 15 MN 21 S 15 WI 22 S 09 MN 35 M 02 MN 22 M 13 MN 25 S 13 WI 20 S 13 MN 26 M 15 WI 27 S 05 MN 23 S 14 IA 21 S 14 MN 29 M 15 MN Tells SAS the data is coming Tells SAS the data is ending 6 RUN; Tells SAS to run the statements

TITLE 'Running the Example Program'; PROC PRINT DATA=DEMO ; VAR gender age marstat credits TITLE 'Running the Example Program'; PROC PRINT DATA=DEMO ; VAR gender age marstat credits fulltime state ; RUN; PROC MEANS DATA=DEMO ; VAR age credits ; RUN; PROC FREQ DATA=DEMO ; TABLES gender ; RUN;

Files Generated When SAS Program is RUN • Log file – a text file Files Generated When SAS Program is RUN • Log file – a text file listing program statements processed and giving notes, warnings and errors (in UNIX the file will be named fname. log) • Output file – a text file giving the output generated from the PROCs (in UNIX the file will be named fname. lst)

Some common procedures: (See also Chapter 20 of C&S) PROC PRINT • print out Some common procedures: (See also Chapter 20 of C&S) PROC PRINT • print out your data - always a good idea!! PROC MEANS • descriptive statistics for continuous data PROC FREQ • descriptive statistics for categorical data PROC UNIVARIATE • very detailed descriptive statistics for continuous data PROC TTEST • performs t-tests (continuous data)

PROC MEANS N MEAN MIN MAXDEC=2; VAR age credits; CLASS gender; RUN; • Displays PROC MEANS N MEAN MIN MAXDEC=2; VAR age credits; CLASS gender; RUN; • Displays descriptive statistics of age and number of credits. • The CLASS statement is optional - it displays the statistics by gender

PROC FREQ DATA = DEMO; TABLES gender fulltime; RUN; • Displays the distribution of PROC FREQ DATA = DEMO; TABLES gender fulltime; RUN; • Displays the distribution of gender and fulltime status (each distribution separately)

PROC UNIVARIATE DATA = DEMO PLOT; VAR age; RUN; NORMAL • Displays descriptive statistics PROC UNIVARIATE DATA = DEMO PLOT; VAR age; RUN; NORMAL • Displays descriptive statistics for age • NORMAL and PLOT are two options that test for normality and display simple graphs

PROC TTEST DATA = DEMO; CLASS fulltime; VAR age; RUN; • Test for a PROC TTEST DATA = DEMO; CLASS fulltime; VAR age; RUN; • Test for a difference in mean age between fulltime and non-full-time students

PROC CORR DATA = DEMO; VAR age credits; RUN; • Examine the correlation between PROC CORR DATA = DEMO; VAR age credits; RUN; • Examine the correlation between age and number of credits.

Analyzing by groups - BY statement PROC SORT DATA = DEMO; BY gender; RUN; Analyzing by groups - BY statement PROC SORT DATA = DEMO; BY gender; RUN; PROC MEANS DATA = DEMO; BY gender; VAR age credits; RUN; • Examines by gender • Need to sort data first • Most procedures allow BY statements

Analyzing by groups - CLASS statement PROC MEANS DATA = DEMO; CLASS gender; VAR Analyzing by groups - CLASS statement PROC MEANS DATA = DEMO; CLASS gender; VAR age credits; RUN; • • Examines data by gender Don’t need to sort first Can use with PROC TTEST CLASS statement sometimes not allowed OR is treated differently in other procedures

Analyzing subgroups - WHERE statement PROC MEANS DATA = DEMO; WHERE gender = ‘F’; Analyzing subgroups - WHERE statement PROC MEANS DATA = DEMO; WHERE gender = ‘F’; VAR age credits; RUN; • Only looks at females • Can subset using numeric or character variables • Can subset in data step using “if” statements

Finding help for SAS Online SAS manual at http: //v 8 doc. sas. com Finding help for SAS Online SAS manual at http: //v 8 doc. sas. com Link on class website.

Using SAS two different ways • • SAS on the PC -Windows environment, pull Using SAS two different ways • • SAS on the PC -Windows environment, pull down menus, nice graphing, color-coded program editor -If you want to buy it…costs $150 for a yearly user license from http: //www 1. umn. edu/adcs/site/sas. html SAS on Unix -Single window, programs run in batch mode, have to learn some Unix commands, high resolution graphics must be exported to PC -While you are taking PH 5415 you will have access to SAS via telnet into the biostatistics Unix system. You can use SAS from your home computer (or any computer that has internet access) by dialing into the biostatistics “saturn” computer name: saturn. biostat. umn. edu

SAS on the PC Several key windows – See numbered windows on “Window” menu SAS on the PC Several key windows – See numbered windows on “Window” menu Editor – where you write or edit SAS code Log – gives details about code you’ve run Output – results (if your code didn’t have fatal errors) Results – manages output Explorer – manages data sets

PC SAS ENVIRONMENT PC SAS ENVIRONMENT

Connecting to Biostatistics Computer for PH 5415 Unix SAS – (batch mode SAS) Home Connecting to Biostatistics Computer for PH 5415 Unix SAS – (batch mode SAS) Home Office Via Telnet Biostatistics Computer saturn. biostat. umn. edu Computer Lab

SAS on Saturn Put your code in one file (. sas file) SAS job SAS on Saturn Put your code in one file (. sas file) SAS job is submitted to processor. log file contains details on your code. lst file contains output (if there were no fatal errors)

SAS on Saturn • Copy SAS program to your home directory (or edit a SAS on Saturn • Copy SAS program to your home directory (or edit a new SAS program) cp /home/ph 5415/programs/tryit. sas ~/ • Type “sas” and the file name sas tryit. sas • View (“less”) the log and output less tryit. log • FTP output to PC

SAS on the PC • Copy SAS program from the web-site • Open SAS SAS on the PC • Copy SAS program from the web-site • Open SAS V 8 on desktop (double click icon) • Paste SAS program into Editor • Click on “Submit” icon or “Submit” from Run menu • Copy and paste output into a Word document