1 / 26

Today:

Today:. Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC. Raw Data. Read in Data Process Data (Create new variables) Output Data (Create SAS Dataset). Data Step. Analyze Data Using Statistical Procedures. PROCs.

sheba
Download Presentation

Today:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. * 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 > 12then 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'; PROCPRINTDATA=DEMO ; VAR gender age marstat credits fulltime state ; RUN;

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

  5. 5 DATALINES; Tells SAS the data is coming 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 ; Tells SAS the data is ending 6 RUN; Tells SAS to run the statements

  6. TITLE'Running the Example Program'; PROCPRINTDATA=DEMO ; VAR gender age marstat credits fulltime state ; RUN; PROCMEANSDATA=DEMO ; VAR age credits ; RUN; PROC FREQ DATA=DEMO ; TABLES gender ; RUN;

  7. 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)

  8. 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)

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

  10. PROC FREQ PROCFREQDATA = DEMO; TABLES gender fulltime; RUN; • Displays the distribution of gender and full-time status (each distribution separately)

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

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

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

  14. Analyzing by groups - BY statement PROCSORTDATA = DEMO; BY gender; RUN; PROCMEANSDATA = DEMO; BY gender; VAR age credits; RUN; • Examines by gender • Need to sort data first • Most procedures allow BY statements

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

  16. Analyzing subgroups - WHERE statement PROCMEANSDATA = 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

  17. Finding help for SAS Online SAS manual at http://v8doc.sas.com Link on class website.

  18. 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://www1.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 PH5415 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. computer name: saturn.biostat.umn.edu

  19. 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

  20. PC SAS ENVIRONMENT

  21. Home BiostatisticsComputer Office Computer Lab Connecting to Biostatistics Computer for PH5415Unix SAS – (batch mode SAS) Via Telnet saturn.biostat.umn.edu

  22. 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)

  23. SAS on Saturn • Copy SAS program to your home directory (or edit a new SAS program) cp /home/ph5415/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

  24. SAS on the PC • Copy SAS program from the web-site • Open SAS V8 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

More Related