Docsity

SAS Data Manipulation and Analysis: Fast Facts - Prof. Kathleen B. Welch, Exams of Biostatistics

Toggle sidebar
bg1
Fast Facts for SAS
Biostat 510
1. Read in raw data from an ASCII file using an infile statement.
data march;
infile "marflt.dat";
input flight 1-3
@4 date mmddyy6.
@10 time time5.
orig $ 15-17
dest $ 18-20
@21 miles comma5.
mail 26-29
freight 30-33
boarded 34-36
transfer 37-39
nonrev 40-42
deplane 43-45
capacity 46-48;
format date mmddyy10. time time5. miles comma5.;
label flight="Flight number"
orig ="Origination City"
dest ="Destination City";
run;
2. Import an Excel File using Proc Import (alternatively, use the Import Wizard):
PROC IMPORT OUT= WORK.MARCH
DATAFILE= "MARCH.XLS"
DBMS=EXCEL REPLACE;
SHEET="march$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
3. Read in raw data from a CSV (comma separated values) file.
data pulse;
infile "pulse.csv" firstobs=2 delimiter="," missover;
input pulse1 pulse2 ran smokes sex height weight activity;
run;
1
pf3
pf4

Partial preview of the text

Download SAS Data Manipulation and Analysis: Fast Facts - Prof. Kathleen B. Welch and more Exams Biostatistics in PDF only on Docsity!

Fast Facts for SAS

Biostat 510

  1. Read in raw data from an ASCII file using an infile statement. data march; infile "marflt.dat"; input flight 1 - 3 @ 4 date mmddyy6. @ 10 time time5. orig $ 15 - 17 dest $ 18 - 20 @ 21 miles comma5. mail 26 - 29 freight 30 - 33 boarded 34 - 36 transfer 37 - 39 nonrev 40 - 42 deplane 43 - 45 capacity 46 - 48 ; format date mmddyy10. time time5. miles comma5.; label flight="Flight number" orig ="Origination City" dest ="Destination City"; run;
  2. Import an Excel File using Proc Import (alternatively, use the Import Wizard ): PROC IMPORT OUT= WORK.MARCH DATAFILE= "MARCH.XLS" DBMS=EXCEL REPLACE; SHEET="march$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN ;
  3. Read in raw data from a CSV (comma separated values) file. data pulse; infile "pulse.csv" firstobs= 2 delimiter="," missover; input pulse1 pulse2 ran smokes sex height weight activity; run ;
  1. Convert an SPSS portable file into a SAS data set: filenam e file1 "cars.por"; proc convert spss=file1 out=cars; run ;
  2. Read in a Permanent SAS data set , and create a temporary data set: libname sasdata2 "C:\Documents and Settings\kwelch\Desktop\sasdata2"; data bank; set sasdata2.bank; run ; Or, to use the permanent SAS data set for analysis directly: libname sasdata2 "C:\Documents and Settings\kwelch\Desktop\sasdata2"; proc means data=sasdata2.bank; run ; Another way to use the permanent SAS data set directly, without setting up a libname statement: proc means data="C:\Documents and Settings\kwelch\Desktop\sasdata2\bank.sas7bdat"; run ; Or: proc means data="C:\Documents and Settings\kwelch\Desktop\sasdata2\bank"; run ;
  3. Read a SAS transport file into a regular SAS data set: libname trans xport "c:\temp\sasdata2\bank.xpt"; proc copy in=trans out=sasdata2; run ; 7. Rules for SAS statements:  They start with a keyword, such as proc or var.  They can be any length.  They end with a semicolon (;). 8. Rules for SAS names:  They can have only letters, numbers, and underscores in them.  They may not start with a number.  They may not have any blanks.  They can be upper or lower case.  SAS versions 7 through 9 allow variable names of up to 32 characters.  SAS version 6 only allows variable names of up to 8 characters.  Library names must only be 8 characters or less. 9. SAS Data step:

Proc ttest (independent samples t-test) Proc Npar1way (Wilcoxon non-parametric analog of t-test) Paired Data (correlated data) Proc ttest (paired t-test) Three or More Independent Samples Proc GLM (oneway analysis of variance (ANOVA)) Proc Npar1way (Kruskal-Walis non-parametric analog of oneway ANOVA) Modeling: Proc Reg Linear regression models for continuous dependent variable, continuous, ordinal or binary predictors (prior creation of dummy variables required for categorical predictors with more than 2 levels, interactions must be created prior to running model) Proc GLM Linear models for continuous dependent variable, predictors may be nominal, ordinal, or continuous. Proc Mixed Linear mixed models for continuous dependent variable, longitudinal or clustered data; predictors may be nominal, ordinal, or continuous. Proc Nlin Nonlinear models for different types of dependent variables. Proc Nlmixed Nonlinear mixed models