Difference between revisions of "Executing SAS and R Scripts in Repository"

From PHUSE Wiki
Jump to: navigation, search
Line 8: Line 8:
 
2) how to execute scripts which are hosted in the Code Repository
 
2) how to execute scripts which are hosted in the Code Repository
  
'''How to access dataset files which are hosted in the Code Repository
+
'''1. How to access dataset files which are hosted in the Code Repository
 
'''
 
'''
  
Line 19: Line 19:
 
'''To access this dataset in SAS, here's the code to use:'''
 
'''To access this dataset in SAS, here's the code to use:'''
  
''filename source url
+
  filename source url "http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/data/adsl.xpt")
"http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/data/adsl.xpt")
+
  libname source xport ;
 
+
  data work.adsl ;
''libname source xport ;
+
  set source.adsl ;
 
+
  run ;
''data work.adsl ;
 
''
 
''set source.adsl ;
 
''
 
''run ;
 
''''
 
  
 
'''To access this dataset in R, here's the code to use:'''
 
'''To access this dataset in R, here's the code to use:'''
  
''library(SASxport)
+
  library(SASxport)
 
+
  adsl <- read.xport(file="http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/data/adsl.xpt")
adsl <- read.xport(file=
 
"http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/data/adsl.xpt")
 
''
 
  
 
(note that the easily-available R package "SASxport" needs to be installed)
 
(note that the easily-available R package "SASxport" needs to be installed)
  
'''How to execute SAS and R scripts which are hosted in the Code Repository
+
'''2. How to execute SAS and R scripts which are hosted in the Code Repository
 
'''
 
'''
  
Line 57: Line 48:
 
'''
 
'''
  
''source("http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/src/adsl.R",echo=T)
+
  source("http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/src/adsl.R",echo=T)
''
+
 
  
 
'''To execute the SAS script in your SAS environment, execute:
 
'''To execute the SAS script in your SAS environment, execute:
 
'''
 
'''
  
''options source2 ;
+
  options source2 ;
 
+
  filename code url "http://phuse-scripts.googlecode.com/svn/trunk/lang/SAS/report/test/src/summary.sas" ;
''filename code url
+
  %include code ;
''
 
"http://phuse-scripts.googlecode.com/svn/trunk/lang/SAS/report/test/src/summary.sas" ;
 
 
 
''%include code ;
 
''''
 

Revision as of 09:11, 20 August 2013

Instructions for accessing datasets and executing SAS and R scripts which exist in the PhUSE/FDA Code Repository

This Wiki page is an attempt to describe two things:

1) how to access dataset files which are hosted in the Code Repository

2) how to execute scripts which are hosted in the Code Repository

1. How to access dataset files which are hosted in the Code Repository

The ADSL dataset created as part of the CDISC ADaM Pilot project is currently hosted in the repository as:

https://code.google.com/p/phuse-scripts/source/browse/trunk/lang/R/report/test/data/adsl.xpt

(this is a SAS Version 5 transport file)

To access this dataset in SAS, here's the code to use:

 filename source url "http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/data/adsl.xpt")
 libname source xport ;
 data work.adsl ;
 set source.adsl ;
 run ;

To access this dataset in R, here's the code to use:

 library(SASxport)
 adsl <- read.xport(file="http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/data/adsl.xpt")

(note that the easily-available R package "SASxport" needs to be installed)

2. How to execute SAS and R scripts which are hosted in the Code Repository

Two example scripts are hosted in the respository for you to test:

R Script:

https://code.google.com/p/phuse-scripts/source/browse/trunk/lang/R/report/test/src/adsl.R

SAS script:

https://code.google.com/p/phuse-scripts/source/browse/trunk/lang/SAS/report/test/src/summary.sas

To execute the R script in your R environment, execute:

 source("http://phuse-scripts.googlecode.com/svn/trunk/lang/R/report/test/src/adsl.R",echo=T)


To execute the SAS script in your SAS environment, execute:

 options source2 ;
 filename code url "http://phuse-scripts.googlecode.com/svn/trunk/lang/SAS/report/test/src/summary.sas" ;
 %include code ;