SlideShare a Scribd company logo
1 of 15
Bringing the SAS Legacy into
     the R Environment
  A Brief Talk for SAS and non-SAS
          Data Professionals



                www.directeffects.net
                Georgette Asherman, 201 673-4301
What is SAS?
•  The company
  –  SAS, Inc. positions itself now as ‘the leader in
     business analytics software and services, and the
     largest independent vendor in the business
     intelligence market.’ Broad range of enterprise
     products.
  –  Sales in 2008 2.26 bil. Up from 1.13 bil. in 2001
  –  120 countries, 45,000 customer organizations, 92 of
     the Fortune 100 have a product of theirs.
•  The core product-SAS® 9.2-An integrated
   language and analytics package that supports
   various add-ons in a common environment
The Legacy
             Jim Goodnight, a
      statistician at North Carolina
      State, wrote the ‘Statistical
      Analysis System.’ He and
      three others started The SAS
      Institute as a company in 1976.
      The company remains
      privately-held and is known for
      its full-service employee-
      friendly campus. They
      remained in core product but
      incorporated current
      technology as it becomes
      mainstream. This year they
      introduced an interface with R
      with their IML®/Studio Product.
Data Structures
           SAS Dataset                           R Data Frame
Obs. No.   Subject   City   Score   Row     Subject   City      Score
                                    Label
1                                   1
2                                   2
3                                   3
4                                   4
5                                   5
6                                   6
7                                   7
8                                   8
Comparison of R Data frame and
              SAS Dataset
         SAS Dataset                               R Data Frame

1.    Each named column                 1.    Each column contains one
      contains one type of data.              type of data. Really a list of
      Really a stack of rows                  named vectors
2.    No row names but                  2.    Row names-default to row
      observation numbers, _N_                numbers and retained
3.    Subsetting via statements         3.    Subsetting via [rows, cols]
      such as IF, WHERE, KEEP
                                        4.    Extensive functions for
      DROP
                                              reading in flat files and other
4.    INFILE statement and INPUT              proprietary data formats
      statements work for flat files.
      PROC IMPORT reads in
      EXCEL files.
The SAS Computing Structure
       Macro Language and Macro Variables




                    Data Step




               Procedures (PROCs)
A SAS Session in Windows
The Data Sets
Why people love SAS
proc contents data                load(file = “filesfromSAS.RData”)
=sashelp.shoes;                   shoes$netsales<-shoes$sales-shoes$returns
run;
                                  set.seed(23)
data work.shoes; set
sashelp.shoes;                    shoes$var.for.random<- runif(nrow(shoes))
   netsales=sales-returns;        #need Hmisc package to add variable
   var_for_random=ranuni(23);          labels
label                             str(shoes)
  netsales="Sales Adjusted for    #Hmisc also has something more like
Returns"                               PROC CONTENTS
  var_for_random="Random Number
from Uniform Distribution";
format netsales dollar8.0;
run;

Language not case sensitive!
Why people hate SAS
data sim1;                          set.seed(23)
  do i=1 to 100;                    var.for.random<-runif(100)
 var_for_random=ranuni(23);         #Can do anything with the vector
                                         now-rename, add to a list, bind to
  output;                                a dataset, etc.
   end;
   drop i;
  run;

*Data set with 1 variable and 100
  rows.
The SAS Concept of Output
     In Version 8.0, SAS introduced the Output Delivery
     System (ODS). This new language structure freed
     users from the default text-based list output. It allows the
     following:
•    Send output to RTF, EXCEL, HTML and PDF formats.
•    Modify output with template language.
•    Modify default output and access requested output as
     SAS datasets.
•    Retained OUTPUT statement for older procedures but
     new procedures now use ODS statements to make data
     sets for statistics, residuals and other analysis files.
•    New ODS Graphics in Version 9.2.
Descriptive Statistics
*default output from PROC             summary(shoes)
PROC MEANS data=work.shoes;           #default output-use other functions to
    RUN;                                  get different statistics
*default output from PROC-can use     output.for.shoes<-summary(shoes)
    statements to change ;
                                      #output with class ‘table’. Similar to
                                          list. Counts for factors and
PROC MEANS data=work.shoes noprint;       percentiles for numeric variables
  OUTPUT out=work.meansdata;
    RUN;
*send to an OUTPUT data set;

PROC PRINT data =meansdata;
Class Level Processing
•    There is a BY Statement that          •   by function similar to SAS BY
     requires data grouped by                  statement but does accepts a data
     classification level or pre-sorted.       frame in any ordering. Results in
•    There is a more flexible CLASS            output of class table
     Statement                             by.output<-by(shoes[c("Sales")], shoes[c
                                               ("Region","Product")],mean)
proc means data =shoes mean
   noprint;                                •   aggregate results in data frame and
     var sales;                                tapply in matrix
    output out=classdata                   ag.output<-aggregate(shoes$Sales,by=shoes[c
   mean=mean ;                                 ("Region","Product")],mean)
     class region product;
   run;                                    tapply.output<-tapply(shoes$Sales,shoes[c
                                               ("Region","Product")],mean)
                                           Need to write new function in order to get all
                                               the levels into one data object.
proc print data=classdata noobs;
   run;
Simple Linear Regression
•    Different PROCs available for          •   lm function – Limited default
     regression depending on you                output so assign to a list object
     focus-output a little different from       with class “lm”
     each                                   attach(shoes)
                                            lmexample<-lm(Returns~Sales
Proc GLM;                                       +Inventory)
Model Returns=Sales Inventory;              summary(lmexample)
Run;
Proc REG;                                   •    Summary function for lm gives
Model Returns=sales inventory;                   nearly the same output as PROC
                                                 REG.
Run;

Different PROCs such as GENMOD
    for non-normal errors such as
    logistic regression
Recommended Books
R For SAS and SPSS Users, Robert A. Muenchen,
  Springer Science & Business Media: New York, 2009
Applied Statistics and the SAS Programming
  Language, 5th ed. Ronald P. Cody and Jeffrey Smith,
  Prentice Hall: New York, 2005
The Little SAS Book: A Primer, 4th ed.Lora Delwich and
  Susan Slaughter, SAS Institute: Cary 2008

Documentation and support available on SAS Website
www.support.sas.com
SAS and IML are registered trademarks of SAS, Inc.
See txt and rtf files for output discussed in this talk.

More Related Content

What's hot

SAS Access / SAS Connect
SAS Access / SAS ConnectSAS Access / SAS Connect
SAS Access / SAS Connectguest2160992
 
Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SASguest2160992
 
Improving Effeciency with Options in SAS
Improving Effeciency with Options in SASImproving Effeciency with Options in SAS
Improving Effeciency with Options in SASguest2160992
 
Introduction to SAS Data Set Options
Introduction to SAS Data Set OptionsIntroduction to SAS Data Set Options
Introduction to SAS Data Set OptionsMark Tabladillo
 
Sharing names and address cleaning patterns for Patstat
Sharing names and address cleaning patterns for PatstatSharing names and address cleaning patterns for Patstat
Sharing names and address cleaning patterns for PatstatGianluca Tarasconi
 
Lightweight ETL pipelines with mara (PyData Berlin September Meetup)
Lightweight ETL pipelines with mara (PyData Berlin September Meetup)Lightweight ETL pipelines with mara (PyData Berlin September Meetup)
Lightweight ETL pipelines with mara (PyData Berlin September Meetup)Martin Loetzsch
 
Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processingguest2160992
 
Data Warehousing with Python
Data Warehousing with PythonData Warehousing with Python
Data Warehousing with PythonMartin Loetzsch
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sashalasti
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL ISankhya_Analytics
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Languageguest2160992
 
R Text-Based Data I/O and Data Frame Access and Manupulation
R Text-Based Data I/O and Data Frame Access and ManupulationR Text-Based Data I/O and Data Frame Access and Manupulation
R Text-Based Data I/O and Data Frame Access and ManupulationIan Cook
 
Introduction to SAS
Introduction to SASIntroduction to SAS
Introduction to SASizahn
 

What's hot (20)

SAS Access / SAS Connect
SAS Access / SAS ConnectSAS Access / SAS Connect
SAS Access / SAS Connect
 
SAS Macros
SAS MacrosSAS Macros
SAS Macros
 
Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SAS
 
Improving Effeciency with Options in SAS
Improving Effeciency with Options in SASImproving Effeciency with Options in SAS
Improving Effeciency with Options in SAS
 
Mssql to oracle
Mssql to oracleMssql to oracle
Mssql to oracle
 
Introduction to SAS Data Set Options
Introduction to SAS Data Set OptionsIntroduction to SAS Data Set Options
Introduction to SAS Data Set Options
 
SAS ODS HTML
SAS ODS HTMLSAS ODS HTML
SAS ODS HTML
 
Sharing names and address cleaning patterns for Patstat
Sharing names and address cleaning patterns for PatstatSharing names and address cleaning patterns for Patstat
Sharing names and address cleaning patterns for Patstat
 
Lightweight ETL pipelines with mara (PyData Berlin September Meetup)
Lightweight ETL pipelines with mara (PyData Berlin September Meetup)Lightweight ETL pipelines with mara (PyData Berlin September Meetup)
Lightweight ETL pipelines with mara (PyData Berlin September Meetup)
 
Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processing
 
Data Warehousing with Python
Data Warehousing with PythonData Warehousing with Python
Data Warehousing with Python
 
Dbms &amp; oracle
Dbms &amp; oracleDbms &amp; oracle
Dbms &amp; oracle
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sas
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Language
 
Sql Document in Testing
Sql Document in TestingSql Document in Testing
Sql Document in Testing
 
R Text-Based Data I/O and Data Frame Access and Manupulation
R Text-Based Data I/O and Data Frame Access and ManupulationR Text-Based Data I/O and Data Frame Access and Manupulation
R Text-Based Data I/O and Data Frame Access and Manupulation
 
Column oriented Transactions
Column oriented TransactionsColumn oriented Transactions
Column oriented Transactions
 
zekeLabs sql-slides
zekeLabs sql-slideszekeLabs sql-slides
zekeLabs sql-slides
 
Introduction to SAS
Introduction to SASIntroduction to SAS
Introduction to SAS
 

Viewers also liked

Ashok GreenBelt Certificate
Ashok GreenBelt CertificateAshok GreenBelt Certificate
Ashok GreenBelt CertificateAshok Krishna
 
An innovation leaders fund modeling the link to growth - feb 2013
An innovation leaders fund   modeling the link to growth - feb 2013An innovation leaders fund   modeling the link to growth - feb 2013
An innovation leaders fund modeling the link to growth - feb 2013Tim Jones
 
certificate_gallbladder
certificate_gallbladdercertificate_gallbladder
certificate_gallbladderMarwan Dweik
 
اختلافات في تراج الكتاب المقدس
اختلافات في تراج الكتاب المقدساختلافات في تراج الكتاب المقدس
اختلافات في تراج الكتاب المقدسosama mostafa
 
Formulario de proposta de novo nome do centro
Formulario de proposta de novo nome do centroFormulario de proposta de novo nome do centro
Formulario de proposta de novo nome do centroYolanda Castro
 
Why Apple and Samsung go to flexible display
Why Apple and Samsung go to flexible displayWhy Apple and Samsung go to flexible display
Why Apple and Samsung go to flexible displayDawson Hun
 

Viewers also liked (13)

Social media activities
Social media activitiesSocial media activities
Social media activities
 
Ashok GreenBelt Certificate
Ashok GreenBelt CertificateAshok GreenBelt Certificate
Ashok GreenBelt Certificate
 
An innovation leaders fund modeling the link to growth - feb 2013
An innovation leaders fund   modeling the link to growth - feb 2013An innovation leaders fund   modeling the link to growth - feb 2013
An innovation leaders fund modeling the link to growth - feb 2013
 
Hello world
Hello worldHello world
Hello world
 
Relatorio_TIC_2012
Relatorio_TIC_2012Relatorio_TIC_2012
Relatorio_TIC_2012
 
certificate_gallbladder
certificate_gallbladdercertificate_gallbladder
certificate_gallbladder
 
Solution baupc 2004
Solution baupc 2004Solution baupc 2004
Solution baupc 2004
 
CV (Yasir Qureshi)
CV (Yasir Qureshi)CV (Yasir Qureshi)
CV (Yasir Qureshi)
 
اختلافات في تراج الكتاب المقدس
اختلافات في تراج الكتاب المقدساختلافات في تراج الكتاب المقدس
اختلافات في تراج الكتاب المقدس
 
Formulario de proposta de novo nome do centro
Formulario de proposta de novo nome do centroFormulario de proposta de novo nome do centro
Formulario de proposta de novo nome do centro
 
Carcinogénesis no relacionada con daño al ADN
Carcinogénesis no relacionada con daño al ADNCarcinogénesis no relacionada con daño al ADN
Carcinogénesis no relacionada con daño al ADN
 
Why Apple and Samsung go to flexible display
Why Apple and Samsung go to flexible displayWhy Apple and Samsung go to flexible display
Why Apple and Samsung go to flexible display
 
chitravel resume
chitravel resumechitravel resume
chitravel resume
 

Similar to Bringing the SAS Legacy into the R Environment: A Brief Introduction

Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2rowensCap
 
Sas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary ToolSas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary Toolsysseminar
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sasAjay Ohri
 
Introducción al Software Analítico SAS
Introducción al Software Analítico SASIntroducción al Software Analítico SAS
Introducción al Software Analítico SASJorge Rodríguez M.
 
Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)Barry DeCicco
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8thotakoti
 
Is Revolution R Enterprise Faster than SAS? Benchmarking Results Revealed
Is Revolution R Enterprise Faster than SAS? Benchmarking Results RevealedIs Revolution R Enterprise Faster than SAS? Benchmarking Results Revealed
Is Revolution R Enterprise Faster than SAS? Benchmarking Results RevealedRevolution Analytics
 
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...Amazon Web Services
 
SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...
SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...
SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...Edureka!
 
Best Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache SparkBest Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache SparkDatabricks
 
SAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-PointSAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-Pointcpointss
 
20180420 hk-the powerofmysql8
20180420 hk-the powerofmysql820180420 hk-the powerofmysql8
20180420 hk-the powerofmysql8Ivan Ma
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Serban Tanasa
 
Data Access Tech Ed India
Data Access   Tech Ed IndiaData Access   Tech Ed India
Data Access Tech Ed Indiarsnarayanan
 
Programmability in spss 14
Programmability in spss 14Programmability in spss 14
Programmability in spss 14Armand Ruis
 

Similar to Bringing the SAS Legacy into the R Environment: A Brief Introduction (20)

Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2
 
SAS Internal Training
SAS Internal TrainingSAS Internal Training
SAS Internal Training
 
SAS - Training
SAS - Training SAS - Training
SAS - Training
 
SAS Programming Notes
SAS Programming NotesSAS Programming Notes
SAS Programming Notes
 
Sas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary ToolSas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary Tool
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sas
 
Introducción al Software Analítico SAS
Introducción al Software Analítico SASIntroducción al Software Analítico SAS
Introducción al Software Analítico SAS
 
Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)
 
Sas
SasSas
Sas
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8
 
Is Revolution R Enterprise Faster than SAS? Benchmarking Results Revealed
Is Revolution R Enterprise Faster than SAS? Benchmarking Results RevealedIs Revolution R Enterprise Faster than SAS? Benchmarking Results Revealed
Is Revolution R Enterprise Faster than SAS? Benchmarking Results Revealed
 
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
 
pm1
pm1pm1
pm1
 
SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...
SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...
SAS Programming For Beginners | SAS Programming Tutorial | SAS Tutorial | SAS...
 
Best Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache SparkBest Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache Spark
 
SAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-PointSAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-Point
 
20180420 hk-the powerofmysql8
20180420 hk-the powerofmysql820180420 hk-the powerofmysql8
20180420 hk-the powerofmysql8
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
 
Data Access Tech Ed India
Data Access   Tech Ed IndiaData Access   Tech Ed India
Data Access Tech Ed India
 
Programmability in spss 14
Programmability in spss 14Programmability in spss 14
Programmability in spss 14
 

Bringing the SAS Legacy into the R Environment: A Brief Introduction

  • 1. Bringing the SAS Legacy into the R Environment A Brief Talk for SAS and non-SAS Data Professionals www.directeffects.net Georgette Asherman, 201 673-4301
  • 2. What is SAS? •  The company –  SAS, Inc. positions itself now as ‘the leader in business analytics software and services, and the largest independent vendor in the business intelligence market.’ Broad range of enterprise products. –  Sales in 2008 2.26 bil. Up from 1.13 bil. in 2001 –  120 countries, 45,000 customer organizations, 92 of the Fortune 100 have a product of theirs. •  The core product-SAS® 9.2-An integrated language and analytics package that supports various add-ons in a common environment
  • 3. The Legacy Jim Goodnight, a statistician at North Carolina State, wrote the ‘Statistical Analysis System.’ He and three others started The SAS Institute as a company in 1976. The company remains privately-held and is known for its full-service employee- friendly campus. They remained in core product but incorporated current technology as it becomes mainstream. This year they introduced an interface with R with their IML®/Studio Product.
  • 4. Data Structures SAS Dataset R Data Frame Obs. No. Subject City Score Row Subject City Score Label 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8
  • 5. Comparison of R Data frame and SAS Dataset SAS Dataset R Data Frame 1.  Each named column 1.  Each column contains one contains one type of data. type of data. Really a list of Really a stack of rows named vectors 2.  No row names but 2.  Row names-default to row observation numbers, _N_ numbers and retained 3.  Subsetting via statements 3.  Subsetting via [rows, cols] such as IF, WHERE, KEEP 4.  Extensive functions for DROP reading in flat files and other 4.  INFILE statement and INPUT proprietary data formats statements work for flat files. PROC IMPORT reads in EXCEL files.
  • 6. The SAS Computing Structure Macro Language and Macro Variables Data Step Procedures (PROCs)
  • 7. A SAS Session in Windows
  • 9. Why people love SAS proc contents data load(file = “filesfromSAS.RData”) =sashelp.shoes; shoes$netsales<-shoes$sales-shoes$returns run; set.seed(23) data work.shoes; set sashelp.shoes; shoes$var.for.random<- runif(nrow(shoes)) netsales=sales-returns; #need Hmisc package to add variable var_for_random=ranuni(23); labels label str(shoes) netsales="Sales Adjusted for #Hmisc also has something more like Returns" PROC CONTENTS var_for_random="Random Number from Uniform Distribution"; format netsales dollar8.0; run; Language not case sensitive!
  • 10. Why people hate SAS data sim1; set.seed(23) do i=1 to 100; var.for.random<-runif(100) var_for_random=ranuni(23); #Can do anything with the vector now-rename, add to a list, bind to output; a dataset, etc. end; drop i; run; *Data set with 1 variable and 100 rows.
  • 11. The SAS Concept of Output In Version 8.0, SAS introduced the Output Delivery System (ODS). This new language structure freed users from the default text-based list output. It allows the following: •  Send output to RTF, EXCEL, HTML and PDF formats. •  Modify output with template language. •  Modify default output and access requested output as SAS datasets. •  Retained OUTPUT statement for older procedures but new procedures now use ODS statements to make data sets for statistics, residuals and other analysis files. •  New ODS Graphics in Version 9.2.
  • 12. Descriptive Statistics *default output from PROC summary(shoes) PROC MEANS data=work.shoes; #default output-use other functions to RUN; get different statistics *default output from PROC-can use output.for.shoes<-summary(shoes) statements to change ; #output with class ‘table’. Similar to list. Counts for factors and PROC MEANS data=work.shoes noprint; percentiles for numeric variables OUTPUT out=work.meansdata; RUN; *send to an OUTPUT data set; PROC PRINT data =meansdata;
  • 13. Class Level Processing •  There is a BY Statement that •  by function similar to SAS BY requires data grouped by statement but does accepts a data classification level or pre-sorted. frame in any ordering. Results in •  There is a more flexible CLASS output of class table Statement by.output<-by(shoes[c("Sales")], shoes[c ("Region","Product")],mean) proc means data =shoes mean noprint; •  aggregate results in data frame and var sales; tapply in matrix output out=classdata ag.output<-aggregate(shoes$Sales,by=shoes[c mean=mean ; ("Region","Product")],mean) class region product; run; tapply.output<-tapply(shoes$Sales,shoes[c ("Region","Product")],mean) Need to write new function in order to get all the levels into one data object. proc print data=classdata noobs; run;
  • 14. Simple Linear Regression •  Different PROCs available for •  lm function – Limited default regression depending on you output so assign to a list object focus-output a little different from with class “lm” each attach(shoes) lmexample<-lm(Returns~Sales Proc GLM; +Inventory) Model Returns=Sales Inventory; summary(lmexample) Run; Proc REG; •  Summary function for lm gives Model Returns=sales inventory; nearly the same output as PROC REG. Run; Different PROCs such as GENMOD for non-normal errors such as logistic regression
  • 15. Recommended Books R For SAS and SPSS Users, Robert A. Muenchen, Springer Science & Business Media: New York, 2009 Applied Statistics and the SAS Programming Language, 5th ed. Ronald P. Cody and Jeffrey Smith, Prentice Hall: New York, 2005 The Little SAS Book: A Primer, 4th ed.Lora Delwich and Susan Slaughter, SAS Institute: Cary 2008 Documentation and support available on SAS Website www.support.sas.com SAS and IML are registered trademarks of SAS, Inc. See txt and rtf files for output discussed in this talk.