On 12/21/21 6:00 PM, Kai Yang via R-help wrote:
Hi team,I'm trying to pass macro variable into R script in Proc iml. I want to do change 
variable in color= and export the result with different file name.If I don't use macro, 
the code work well. But when I try to use macro below, I got error message: "Submit 
block cannot be directly placed in a macro. Instead, place the submit block into a file 
first and then use %include to include the file within a macro definition.". After 
reading the message, I still not sure how to fix the problem in the code. Anyone can help 
me?
Thank you,Kai
%macro pplot(a);proc iml;
submit / R;
library(ggplot2)library(tidyverse)
mpg %>%  filter(hwy <35) %>%   ggplot(aes(x = displ, y = hwy, color = &a)) +   
geom_point()ggsave("c:/temp/&a..jpg")
endsubmit;
quit;%mend;%pplot(drv);%pplot(cyl);

        [[alternative HTML version deleted]]


Two problems I see. 1) you posted to R-help using html whereas the mailing list is a plain text venue, and 2) I reasonably sure that's a SAS error message and we don't consult on SAS problems.

If you strip out the stuff involving "&a" and add back in the elided line-breaks the R code runs without error.

--

David.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to