Doing Macros in R

Macros in SAS are fairly analogous to functions in R

So in your example, one way to do that would be:

psd.func <- function(file){
    read.csv(unzip(paste0("C:/Users/me/Desktop/FAS (PSD)/",file,"_csv.zip"),exdir="C:/Users/me/Desktop/FAS (PSD)"))
}

psd.coffee <- psd.func(file="psd_coffee")

Something to that effect. Definitely double check my code but that's the gist.

EDIT: Updated so that the properly named object is created in the code.
EDIT2: In my previous correction I messed up the function param definition (type of "filet" instead of "file"). Also, for more efficient ways definitely look at @nwerth 's comment

1 Like