Data visualization with SAS programming

SAS to R to SAS Error Messages

Reply
Regular Contributor
Posts: 215

SAS to R to SAS Error Messages

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.

Regular Contributor
Posts: 215

SAS to R to SAS Error Messages

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 &quot;&dir.\program.R&quot; lrecl=1024;

     put 'fv03lesions=read.csv(&quot;fv03_lesiondata.csv&quot;,header=T)';

     put 'brpercent=fv03lesions[,11]';

     put 'color=ifelse(fv-2lesions[,13]==&quot;Positive&quot;,4,2)';

     put &quot;png(file='D:/Documents and Settings/dbateman/Desktop/SAS to R to SAS/program.jpg')&quot;;

     put 'barplot(height=brpercent,width=.5,space=0,col=color,ylim=(-100,125),ylab=&quot;Percent Change in Tumor Size&quotSmiley Wink';

     put 'abline(h=0)';

     put 'legend(&quot;topleft&quot;,lty=1,lwd=5,cex=.8,c(&quot;Positive&quot;,&quot;Negative&quotSmiley Wink,col=c(4,2)';

     put 'dev.off()';

     put 'q()';

run;

OPTIONS NOXWAIT XSYNC;

X &quot;&quot;&quot;D:\Program Files\R\R-2.11.1\bin\Rgui.exe&quot;&quot; --no-save --quiet <&quot;&quot;&dir.\program.R&quot;&quot;> &quot;&quot;&dir.\program.log&quot;&quot;&quot;;

data_null_;

     infile &quot;&dir.\program.log&quot;;

     file log;

     input;

     put '**R: ' _infile_;

run;

ods escapechar='^';

ods rtf file=&quot;&dir.\report.rtf&quot; style=minimal gtitle gfootnote;

data _null_;

     file print;

     put &quot;^S={preimage=&quot;&dir.\program.jpg&quot;}&quot;;

run;

ods _ALL_ close;

SAS Super FREQ
Posts: 3,234

SAS to R to SAS Error Messages

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;

Regular Contributor
Posts: 215

SAS to R to SAS Error Messages

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

SAS Super FREQ
Posts: 3,234

SAS to R to SAS Error Messages

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

SAS Super FREQ
Posts: 3,234

SAS to R to SAS Error Messages

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…

http://robslink.com/SAS/democd41/waterfall_anno.htm

http://robslink.com/SAS/democd41/waterfall_anno_info.htm

SAS Super FREQ
Posts: 3,234

SAS to R to SAS Error Messages

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.

Post a Question
Discussion Stats
  • 6 replies
  • 304 views
  • 0 likes
  • 2 in conversation