[R] problem: try to passing macro value into submit block
dw|n@em|u@ @end|ng |rom comc@@t@net
Wed Dec 22 04:21:50 CET 2021
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;
> mpg %>% filter(hwy <35) %>% ggplot(aes(x = displ, y = hwy, color = &a)) + geom_point()ggsave("c:/temp/&a..jpg")
> [[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.
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help