SlideShare a Scribd company logo
1 of 20
CALLING R FROM SAS/IML
Barry DeCicco
Michigan SAS Users’ Group
February 22, 2018
WHY USE R IF YOU HAVE SAS?
You can SAS for what you already know well, and use R only
as needed.
You might find that you don’t have the capacities in SAS
which you desire.
R has vast and rapidly growing capacities – over 10,000
packages.
BASICS OF R
R must be installed on your computer. Download from CRAN:
https://cran.r-project.org
Necessary packages (modules) must be downloaded from
CRAN and installed: (select ‘Packages’ from the left-hand
menu).
You will need to set up SAS to use R.
SETTING UP SAS TO USE R
You need to edit the file ‘SASv9.cfg’, which controls some
configurations.
Make a copy, and then edit the original, adding these lines:
1. -RLANG
2. -config "C:Program
FilesSASHomeSASFoundation9.4nlsensasv9.cfg“[replace with
folder name for where this file is on your computer]
3. -SET R_HOME "C:Program FilesRR-3.3.3“ [replace with folder
name for where R lives on your computer]
HOW TO SUBMIT R CODE IN SAS
When running analyses/data manipulations in R, there are
things which need to be done:
Setting directories as needed, to pull/save data, output and
graph files.
Loading (already installed!) necessary packages for use
(e.g., ‘ggplot2’ for complex graphs).
These will need to be done in the SAS code
submitted to R each time.
STARTING LINES
Use PROC Options to enable SAS to use R:
proc options option=rlang; run;
Start IML:
Proc IML;
Export SAS datasets to R as needed:
Call ExportDataSetToR(SAS-data-set, RDataFrame);
Let SAS know to start R:
submit / R;
ENDING LINES
Retrieve data sets from R as needed:
 CALL IMPORTDATASETFROMR (SAS-data-set, RExpr) ;
Let SAS know to end sending commands to R:
endsubmit;
Quit IML (if no further IML use is needed):
quit;
R LANGUAGE COMMANDS
Set the working directory (location where R retrieves and
stores files), while storing previous locaton in ‘old_wd’:
 old_wd<-setwd("C:/Users/Barry/Desktop")
Resetting the working directory back to what it was:
setwd(old_wd);
# this is a comment
GOING THROUGH THE LOG -
PRELIMINARIES
 /* Start R options/ */
 proc options option=rlang;
 run;
 proc iml;
 title "Statistic in R (integration with SAS)";
 run ExportDataSetToR("WORK.RCBD_TEST", "RCBD_IN_R");
 submit / R;
GOING THROUGH THE LOG –
SUBMITTING COMMANDS TO R
 #_______Beginning of R code_________________
 # Change the working directory, saving the old one in ‘old_wd’
 old_wd<-setwd("C:/Users/Barry/Desktop")
 # Load the ‘qicharts’ module (package), so that it can be used.
 library(qicharts)
GOING THROUGH THE LOG –
SUBMITTING COMMANDS TO R
 # Create a data fram (data set)
 d2 <- data.frame(y = rnorm(144, 12, 3),
 expand.grid(x = seq.Date(as.Date('2014-1-1'),
 by = 'week',
 length.out = 24),
 g1 = LETTERS[1:3],
 g2 = letters[1:2]))
 # Introduce a shift in process performance
 d2$y[132:144] <- d2$y[132:144] * 3
GOING THROUGH THE LOG –
SUBMITTING COMMANDS TO R
 # Run a chart.
 trc(y ~ x | g1 + g2, data = d2, main = 'Trellis run chart', chart = 'i')
 # Direct the graphics output to a file, then close it.
 dev.copy(pdf,'myplot.pdf',width=6,height=4 )
 dev.off()
 # Reset the working directory
 setwd(old_wd)
GOING THROUGH THE LOG –
WRAPPING UP
 #_______End of R code_________________
 endsubmit;
 * Bring the data set from R to SAS;
 CALL IMPORTDATASETFROMR ("work.d2", "d2") ;
 proc print data=d2;
 run;
RESULT
l
R LANGUAGE COMMANDS II
Set the working directory (location where R retrieves and
stores files), while storing previous locaton in ‘old_wd’:
 old_wd<-setwd("C:/Users/Barry/Desktop")
Resetting the working directory back to what it was:
setwd(old_wd);
# this is a comment
FUTURE PRESENTATIONS
 Ann Arbor Chapter of the American Statistical Association,
April Meeting (April 17)
 More on accessing R from SAS
 How to access SAS from R
 See our Meetup: https://www.meetup.com/Ann-Arbor-
Chapter-of-the-American-Statistical-Association
REFERENCES - SAS
 ‘Run R code inside SAS easily’
https://communities.sas.com/t5/General-SAS-Programming/Run-R-
code-inside-SAS-easily/td-p/210116
 ‘The RLANG System Option’
http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def
ault/viewer.htm#imlug_r_sect003.htm
 ‘Submit R Statements’
http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def
ault/viewer.htm#imlug_r_sect004.htm
REFERENCES – SAS (CON.)
 SAS/IML(R) 9.3 User's Guide ‘The RLANG System Option’
http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def
ault/viewer.htm#imlug_r_sect003.htm
 SAS/IML(R) 9.3 User's Guide‘Submit R Statements’
http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def
ault/viewer.htm#imlug_r_sect004.htm
 SAS/IML(R) 12.1 User's Guide: EXPORTDATASETTOR Call
http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/def
ault/viewer.htm#imlug_langref_sect114.htm
 SAS/IML(R) 12.1 User's Guide: IMPORTDATASETFROMR Call
http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/def
ault/viewer.htm#imlug_langref_sect182.htm
REFERENCES – SAS (CON.)
 ‘Run R code inside SAS easily’ SAS/IML(R) 9.3 User's Guide
‘EXPORTDATASETTOR Call’
http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/default/view
er.htm#imlug_langref_sect114.htm
 SAS Blogs: Video: Calling R from the SAS/IML Language
https://blogs.sas.com/content/iml/2011/10/31/video-calling-r-from-the-sasiml-
language.html
REFERENCES - R
 ‘Saving graphics as pdf files in R’
https://www.stat.berkeley.edu/~paciorek/computingTips/Saving_graphi
cs_as_pdf_file.html

More Related Content

What's hot

Map Reduce Execution Architecture
Map Reduce Execution Architecture Map Reduce Execution Architecture
Map Reduce Execution Architecture Rupak Roy
 
Import and Export Big Data using R Studio
Import and Export Big Data using R StudioImport and Export Big Data using R Studio
Import and Export Big Data using R StudioRupak Roy
 
Introduction to PIG components
Introduction to PIG components Introduction to PIG components
Introduction to PIG components Rupak Roy
 
R hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduceR hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduceAiden Seonghak Hong
 
Introduction to Hbase
Introduction to Hbase Introduction to Hbase
Introduction to Hbase Rupak Roy
 
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabCloudxLab
 
Scripts related to temp tablespace
Scripts related to temp tablespaceScripts related to temp tablespace
Scripts related to temp tablespaceSoumya Das
 
Backup andrecoverychecklist
Backup andrecoverychecklistBackup andrecoverychecklist
Backup andrecoverychecklistpraveen_01236
 
Introduction to R and R Studio
Introduction to R and R StudioIntroduction to R and R Studio
Introduction to R and R StudioRupak Roy
 
ACADILD:: HADOOP LESSON
ACADILD:: HADOOP LESSON ACADILD:: HADOOP LESSON
ACADILD:: HADOOP LESSON Padma shree. T
 
Introductive to Hive
Introductive to Hive Introductive to Hive
Introductive to Hive Rupak Roy
 
Apache Hive Table Partition and HQL
Apache Hive Table Partition and HQLApache Hive Table Partition and HQL
Apache Hive Table Partition and HQLRupak Roy
 
Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...
Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...
Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...CloudxLab
 
Introduction of R on Hadoop
Introduction of R on HadoopIntroduction of R on Hadoop
Introduction of R on HadoopChung-Tsai Su
 
Hadoop basic commands
Hadoop basic commandsHadoop basic commands
Hadoop basic commandsbispsolutions
 
Integrate Hive and R
Integrate Hive and RIntegrate Hive and R
Integrate Hive and RJunHo Cho
 
Hadoop introduction seminar presentation
Hadoop introduction seminar presentationHadoop introduction seminar presentation
Hadoop introduction seminar presentationpuneet yadav
 

What's hot (20)

Map Reduce Execution Architecture
Map Reduce Execution Architecture Map Reduce Execution Architecture
Map Reduce Execution Architecture
 
Import and Export Big Data using R Studio
Import and Export Big Data using R StudioImport and Export Big Data using R Studio
Import and Export Big Data using R Studio
 
Introduction to PIG components
Introduction to PIG components Introduction to PIG components
Introduction to PIG components
 
R hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduceR hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduce
 
Introduction to Hbase
Introduction to Hbase Introduction to Hbase
Introduction to Hbase
 
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
 
Scripts related to temp tablespace
Scripts related to temp tablespaceScripts related to temp tablespace
Scripts related to temp tablespace
 
Backup andrecoverychecklist
Backup andrecoverychecklistBackup andrecoverychecklist
Backup andrecoverychecklist
 
Introduction to R and R Studio
Introduction to R and R StudioIntroduction to R and R Studio
Introduction to R and R Studio
 
ACADILD:: HADOOP LESSON
ACADILD:: HADOOP LESSON ACADILD:: HADOOP LESSON
ACADILD:: HADOOP LESSON
 
Introductive to Hive
Introductive to Hive Introductive to Hive
Introductive to Hive
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 4 lecture-3
Unit 4 lecture-3Unit 4 lecture-3
Unit 4 lecture-3
 
Apache Hive Table Partition and HQL
Apache Hive Table Partition and HQLApache Hive Table Partition and HQL
Apache Hive Table Partition and HQL
 
Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...
Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...
Writing MapReduce Programs using Java | Big Data Hadoop Spark Tutorial | Clou...
 
Introduction of R on Hadoop
Introduction of R on HadoopIntroduction of R on Hadoop
Introduction of R on Hadoop
 
Hadoop basic commands
Hadoop basic commandsHadoop basic commands
Hadoop basic commands
 
Integrate Hive and R
Integrate Hive and RIntegrate Hive and R
Integrate Hive and R
 
Hadoop introduction seminar presentation
Hadoop introduction seminar presentationHadoop introduction seminar presentation
Hadoop introduction seminar presentation
 
Hive(ppt)
Hive(ppt)Hive(ppt)
Hive(ppt)
 

Similar to Calling r from sas (msug meeting, feb 17, 2018) revised

1 Installing & getting started with R
1 Installing & getting started with R1 Installing & getting started with R
1 Installing & getting started with Rnaroranisha
 
1 installing & Getting Started with R
1 installing & Getting Started with R1 installing & Getting Started with R
1 installing & Getting Started with RDr Nisha Arora
 
R the unsung hero of Big Data
R the unsung hero of Big DataR the unsung hero of Big Data
R the unsung hero of Big DataDhafer Malouche
 
exercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdfexercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdfSngB2
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdfBusyBird2
 
Hadoop Installation presentation
Hadoop Installation presentationHadoop Installation presentation
Hadoop Installation presentationpuneet yadav
 
Sas Talk To R Users Group
Sas Talk To R Users GroupSas Talk To R Users Group
Sas Talk To R Users Groupgeorgette1200
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packagesAjay Ohri
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2rowensCap
 
DSpace Tutorial : Open Source Digital Library
DSpace Tutorial : Open Source Digital LibraryDSpace Tutorial : Open Source Digital Library
DSpace Tutorial : Open Source Digital Libraryrajivkumarmca
 
Quick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skillsQuick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skillsRavindra kumar
 
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1Raheel Syed
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in RSamuel Bosch
 

Similar to Calling r from sas (msug meeting, feb 17, 2018) revised (20)

Sas classes in mumbai
Sas classes in mumbaiSas classes in mumbai
Sas classes in mumbai
 
1 Installing & getting started with R
1 Installing & getting started with R1 Installing & getting started with R
1 Installing & getting started with R
 
1 installing & Getting Started with R
1 installing & Getting Started with R1 installing & Getting Started with R
1 installing & Getting Started with R
 
Gur1009
Gur1009Gur1009
Gur1009
 
R the unsung hero of Big Data
R the unsung hero of Big DataR the unsung hero of Big Data
R the unsung hero of Big Data
 
Convert single instance to RAC
Convert single instance to RACConvert single instance to RAC
Convert single instance to RAC
 
exercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdfexercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdf
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdf
 
Overview of Spark for HPC
Overview of Spark for HPCOverview of Spark for HPC
Overview of Spark for HPC
 
Hadoop Installation presentation
Hadoop Installation presentationHadoop Installation presentation
Hadoop Installation presentation
 
Sas Talk To R Users Group
Sas Talk To R Users GroupSas Talk To R Users Group
Sas Talk To R Users Group
 
Rmarkdown cheatsheet-2.0
Rmarkdown cheatsheet-2.0Rmarkdown cheatsheet-2.0
Rmarkdown cheatsheet-2.0
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2
 
Dspace tutorial
Dspace tutorialDspace tutorial
Dspace tutorial
 
DSpace Tutorial : Open Source Digital Library
DSpace Tutorial : Open Source Digital LibraryDSpace Tutorial : Open Source Digital Library
DSpace Tutorial : Open Source Digital Library
 
Quick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skillsQuick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skills
 
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in R
 

More from Barry DeCicco

Easy HTML Tables in RStudio with Tabyl and kableExtra
Easy HTML Tables in RStudio with Tabyl and kableExtraEasy HTML Tables in RStudio with Tabyl and kableExtra
Easy HTML Tables in RStudio with Tabyl and kableExtraBarry DeCicco
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Barry DeCicco
 
Beginning text analysis
Beginning text analysisBeginning text analysis
Beginning text analysisBarry DeCicco
 
Up and running with python
Up and running with pythonUp and running with python
Up and running with pythonBarry DeCicco
 
Using RStudio on AWS
Using RStudio on AWSUsing RStudio on AWS
Using RStudio on AWSBarry DeCicco
 
Calling python from r
Calling python from rCalling python from r
Calling python from rBarry DeCicco
 

More from Barry DeCicco (6)

Easy HTML Tables in RStudio with Tabyl and kableExtra
Easy HTML Tables in RStudio with Tabyl and kableExtraEasy HTML Tables in RStudio with Tabyl and kableExtra
Easy HTML Tables in RStudio with Tabyl and kableExtra
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
 
Beginning text analysis
Beginning text analysisBeginning text analysis
Beginning text analysis
 
Up and running with python
Up and running with pythonUp and running with python
Up and running with python
 
Using RStudio on AWS
Using RStudio on AWSUsing RStudio on AWS
Using RStudio on AWS
 
Calling python from r
Calling python from rCalling python from r
Calling python from r
 

Recently uploaded

Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 

Recently uploaded (20)

Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 

Calling r from sas (msug meeting, feb 17, 2018) revised

  • 1. CALLING R FROM SAS/IML Barry DeCicco Michigan SAS Users’ Group February 22, 2018
  • 2. WHY USE R IF YOU HAVE SAS? You can SAS for what you already know well, and use R only as needed. You might find that you don’t have the capacities in SAS which you desire. R has vast and rapidly growing capacities – over 10,000 packages.
  • 3. BASICS OF R R must be installed on your computer. Download from CRAN: https://cran.r-project.org Necessary packages (modules) must be downloaded from CRAN and installed: (select ‘Packages’ from the left-hand menu). You will need to set up SAS to use R.
  • 4. SETTING UP SAS TO USE R You need to edit the file ‘SASv9.cfg’, which controls some configurations. Make a copy, and then edit the original, adding these lines: 1. -RLANG 2. -config "C:Program FilesSASHomeSASFoundation9.4nlsensasv9.cfg“[replace with folder name for where this file is on your computer] 3. -SET R_HOME "C:Program FilesRR-3.3.3“ [replace with folder name for where R lives on your computer]
  • 5. HOW TO SUBMIT R CODE IN SAS When running analyses/data manipulations in R, there are things which need to be done: Setting directories as needed, to pull/save data, output and graph files. Loading (already installed!) necessary packages for use (e.g., ‘ggplot2’ for complex graphs). These will need to be done in the SAS code submitted to R each time.
  • 6. STARTING LINES Use PROC Options to enable SAS to use R: proc options option=rlang; run; Start IML: Proc IML; Export SAS datasets to R as needed: Call ExportDataSetToR(SAS-data-set, RDataFrame); Let SAS know to start R: submit / R;
  • 7. ENDING LINES Retrieve data sets from R as needed:  CALL IMPORTDATASETFROMR (SAS-data-set, RExpr) ; Let SAS know to end sending commands to R: endsubmit; Quit IML (if no further IML use is needed): quit;
  • 8. R LANGUAGE COMMANDS Set the working directory (location where R retrieves and stores files), while storing previous locaton in ‘old_wd’:  old_wd<-setwd("C:/Users/Barry/Desktop") Resetting the working directory back to what it was: setwd(old_wd); # this is a comment
  • 9. GOING THROUGH THE LOG - PRELIMINARIES  /* Start R options/ */  proc options option=rlang;  run;  proc iml;  title "Statistic in R (integration with SAS)";  run ExportDataSetToR("WORK.RCBD_TEST", "RCBD_IN_R");  submit / R;
  • 10. GOING THROUGH THE LOG – SUBMITTING COMMANDS TO R  #_______Beginning of R code_________________  # Change the working directory, saving the old one in ‘old_wd’  old_wd<-setwd("C:/Users/Barry/Desktop")  # Load the ‘qicharts’ module (package), so that it can be used.  library(qicharts)
  • 11. GOING THROUGH THE LOG – SUBMITTING COMMANDS TO R  # Create a data fram (data set)  d2 <- data.frame(y = rnorm(144, 12, 3),  expand.grid(x = seq.Date(as.Date('2014-1-1'),  by = 'week',  length.out = 24),  g1 = LETTERS[1:3],  g2 = letters[1:2]))  # Introduce a shift in process performance  d2$y[132:144] <- d2$y[132:144] * 3
  • 12. GOING THROUGH THE LOG – SUBMITTING COMMANDS TO R  # Run a chart.  trc(y ~ x | g1 + g2, data = d2, main = 'Trellis run chart', chart = 'i')  # Direct the graphics output to a file, then close it.  dev.copy(pdf,'myplot.pdf',width=6,height=4 )  dev.off()  # Reset the working directory  setwd(old_wd)
  • 13. GOING THROUGH THE LOG – WRAPPING UP  #_______End of R code_________________  endsubmit;  * Bring the data set from R to SAS;  CALL IMPORTDATASETFROMR ("work.d2", "d2") ;  proc print data=d2;  run;
  • 15. R LANGUAGE COMMANDS II Set the working directory (location where R retrieves and stores files), while storing previous locaton in ‘old_wd’:  old_wd<-setwd("C:/Users/Barry/Desktop") Resetting the working directory back to what it was: setwd(old_wd); # this is a comment
  • 16. FUTURE PRESENTATIONS  Ann Arbor Chapter of the American Statistical Association, April Meeting (April 17)  More on accessing R from SAS  How to access SAS from R  See our Meetup: https://www.meetup.com/Ann-Arbor- Chapter-of-the-American-Statistical-Association
  • 17. REFERENCES - SAS  ‘Run R code inside SAS easily’ https://communities.sas.com/t5/General-SAS-Programming/Run-R- code-inside-SAS-easily/td-p/210116  ‘The RLANG System Option’ http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def ault/viewer.htm#imlug_r_sect003.htm  ‘Submit R Statements’ http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def ault/viewer.htm#imlug_r_sect004.htm
  • 18. REFERENCES – SAS (CON.)  SAS/IML(R) 9.3 User's Guide ‘The RLANG System Option’ http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def ault/viewer.htm#imlug_r_sect003.htm  SAS/IML(R) 9.3 User's Guide‘Submit R Statements’ http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/def ault/viewer.htm#imlug_r_sect004.htm  SAS/IML(R) 12.1 User's Guide: EXPORTDATASETTOR Call http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/def ault/viewer.htm#imlug_langref_sect114.htm  SAS/IML(R) 12.1 User's Guide: IMPORTDATASETFROMR Call http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/def ault/viewer.htm#imlug_langref_sect182.htm
  • 19. REFERENCES – SAS (CON.)  ‘Run R code inside SAS easily’ SAS/IML(R) 9.3 User's Guide ‘EXPORTDATASETTOR Call’ http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/default/view er.htm#imlug_langref_sect114.htm  SAS Blogs: Video: Calling R from the SAS/IML Language https://blogs.sas.com/content/iml/2011/10/31/video-calling-r-from-the-sasiml- language.html
  • 20. REFERENCES - R  ‘Saving graphics as pdf files in R’ https://www.stat.berkeley.edu/~paciorek/computingTips/Saving_graphi cs_as_pdf_file.html