-3

I wonder how to use macros in R.

I´m looking for a simple macro so I only need to change for example a date once in a syntax and not on every place where the date is used in the syntax.

In other words like the %let functions in SAS but in R.

2 Answers2

1

a closerlook would suggest that creating your own custom function in R and then calling that function would be like a SAS Macro

e.g

myfunction=function(x){ whatever the macro would do pseduo code}

and then call the function

myfunction(var1)

for %let which is a global variable just assign the value to a constant

but overall quit thinking like SAS and switch to object oriented programming in R

Ajay Ohri
  • 3,136
  • 3
  • 28
  • 60
0

Use a constant instead of explicitly writing it out every time?

TaintedQ
  • 11
  • 2