I am trying to write SAS code to prepare a dataset, send that dataset to R to produce and graph, and send that graph back to SAS to export through ODS. I ran the SAS code that is attached and got the following two error messages:
ARGUMENT '<D:\Documents and Settings\dbateman\Destkop\SAS to R to SAS\program.R>' __ignored__
ARGUMENT 'D:\Documents and Settings\dbateman\Desktop\SAS to R to SAS\program.log' __ignored__
Does anyone know what these mean and how to fix it? I cannot get SAS to run past the X statement and move on to the second DATA _NULL_ step.
I am not sure that my SAS code attached, so here it is just in case:
%let dir=D:\Documents and Settings\dbateman\Desktop\SAS to R to SAS;
data _null_;
file "&dir.\program.R" lrecl=1024;
put 'fv03lesions=read.csv("fv03_lesiondata.csv",header=T)';
put 'brpercent=fv03lesions[,11]';
put 'color=ifelse(fv-2lesions[,13]=="Positive",4,2)';
put "png(file='D:/Documents and Settings/dbateman/Desktop/SAS to R to SAS/program.jpg')";
put 'barplot(height=brpercent,width=.5,space=0,col=color,ylim=(-100,125),ylab="Percent Change in Tumor Size")';
put 'abline(h=0)';
put 'legend("topleft",lty=1,lwd=5,cex=.8,c("Positive","Negative"),col=c(4,2)';
put 'dev.off()';
put 'q()';
run;
OPTIONS NOXWAIT XSYNC;
X """D:\Program Files\R\R-2.11.1\bin\Rgui.exe"" --no-save --quiet <""&dir.\program.R""> ""&dir.\program.log""";
data_null_;
infile "&dir.\program.log";
file log;
input;
put '**R: ' _infile_;
run;
ods escapechar='^';
ods rtf file="&dir.\report.rtf" style=minimal gtitle gfootnote;
data _null_;
file print;
put "^S={preimage="&dir.\program.jpg"}";
run;
ods _ALL_ close;
It looks like you're trying to create a bar chart with a reference line. The VBAR and REFLINE statements in PROC SGPLOT are useful for this. Here's an example:
data tumors;
input Group $ Change;
format Change PERCENT8.;
datalines;
Control 0.02
Control -0.05
Control 0.1
Control 0.5
Control 1.2
DrugA -0.9
DrugA -0.3
DrugA 0
DrugA -0.1
DrugA 0.1
;
run;
proc print;run;
title "Average Percent Change in Tumor Size";
proc sgplot data=tumors;
vbar group / response=change stat=mean;
refline 0 / axis=Y;
run;
Rick,
This does help somewhat. I am trying to make a waterfall plot. My SAS software does not have SAS/IML, and apparently I do not have access to PROC SGPLOT. I am not sure what our license agreement includes, but apparently not those two items. I managed to get something that looks fairly good (I will need to do a lot of adjusting) by using the following code:
proc gchart data=dsn;
vbar barnum / discrete type=sum sumvar=percentchange;
run;
Thanks,
Dallas
Well, good news when you upgrade to SAS 9.3:
1) The SG procedures are in Base SAS
2) PROC SGPLOT includes a WATERFALL statement: http://support.sas.com/documentation/cdl/en/grstatproc/62920/HTML/default/viewer.htm#p0djzh7ah4st4wn...
For earlier versions of SAS, there have been several papers written on how to do this using PROC GPLOT:
http://analytics.ncsu.edu/sesug/2008/SIB-112.pdf
http://support.sas.com/resources/papers/proceedings09/212-2009.pdf
Robert Allison asked me to post this link that shows how to do a waterfall chart using traditional SAS/Graph (gchart, and a little annotate), which should work with any version of SAS shipped within the last 10 or 20 years…
I'll offer two comments:
1) You can seemlessly transfer data between SAS and R by using the SAS/IML language: http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/default/viewer.htm#r_toc.htm I've written about the advantages of calling R from SAS/IML (http://blogs.sas.com/iml/index.php?/archives/140-Calling-R-from-SASIML-Software.html). The R language and the SAS/IML language are both high-level, extensible, matrix/vector languages. If you are tempted to compute something in R, chances are you can also compute it in SAS/IML. See my blog for example of using the SAS/IML language: http://blogs.sas.com/content/iml/
2) The advances in ODS graphics, and especially the Statistical Graphics (SG) procedures have eliminated many of the reasons that SAS customers used to give for using R. Perhaps if you describe the graph you are trying to produce, someone can show you how to create it within SAS.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.