-
Notifications
You must be signed in to change notification settings - Fork 1
/
R2SAS
106 lines (93 loc) · 2.74 KB
/
R2SAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*******************************************************************************
|
| Program Name: R2SAS.sas
|
| Program Version: 01
|
| MDP/Protocol ID:
|
| Program Purpose: To create R plots to pdf using SAS template
|
| SAS Version: 9.2
|
| Created By: Daren Austin
| Date: 16/DEC/2016
|
|*******************************************************************************
| Macros used: %RScript
|
| Parameters:
|
|*******************************************************************************
| Change Log
|
| Modified By:
| Date of Modification:
|
| Modification ID:
| Reason For Modification:
|
|*******************************************************************************
| QC Reviewer:
| Date: XX-XXX-2016
| Items to QC:
| 1) Macro Variables [PASS/FAIL]
| 2) Macro Parameters [PASS/FAIL]
| 6) Other (list) [PASS/FAIL]
|
******************************************
/* http://www.phusewiki.org/wiki/index.php?title=Superior_gRaphics_in_Statistical_Reports */
%macro RScript(Rscript);
data _null_;
file "&Rscript";
infile cards;
input cards;
_infile_ = resolve(_infile_);
put _infile_;
%mend;
/*********************************/
/*** Set path amd SAS filename ***/
/*********************************/
*%let path = d:/R2SAS;
%let path = W:/utilities/R2SAS;
%let reporting = PRELIMINARY;
%include "\\us1dsntv005\rd-cpms-programming\utilities\R2SAS\ClinPharmPlotTemplate_05_BATCH.sas";
/*Files file.r, file.png and file.pdf are produced*/
/*Figure number is asigned from filename automatically*/
/*reporting effort*/
%let file = sampleplot;
%let gDNG = 2017Nxxxxxx_00;
%let gprotocol = Theoph_Sample;
%let gpopulation = Add population here;
/***********************/
/*** Create R script ***/
/***********************/
%RScript(&path/&file..r)
cards4;
#######################
#### Begin R script ###
#######################
##################################################################################
#################### LINES ARE LIMITED TO 80 CHARACTERS ONLY #####################
##################################################################################
setwd("W:/utilities/R2SAS/")
Theoph <- read.csv("Theoph.csv")
xmax<-max(Theoph$Time)
ymax<-max(Theoph$conc)
png("sampleplot.png",width=800, height=500)
plot(Theoph$Time,Theoph$conc,type = 'o',
xlab = 'Time in Hours',xlim=range(0:xmax),
ylab="Concentration in ng/mL",ylim=c(1, ymax),log="y",)
dev.off()
####################
### END R SCRIPT ###
####################
;;;;
run;
%put &path;
%put &path/&file..r;
/************************/
/*** Execute R script ***/
/************************/
x "cd C:\Program Files\R\R-3.4.0\bin\x64"; /**specify the path where R is installed on PC**/;
x "Rscript --vanilla &path/&file..r";