Executing SAS and R Scripts in Repository

From PHUSE Wiki
Revision as of 09:03, 20 August 2013 by Mikec (talk | contribs)
Jump to: navigation, search

Instructions for accessing datasets and executing SAS and R scripts which exist in 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

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)

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 ;