This is a question coming from an R user who is now using SAS for his job.
Basically, I want do something in SAS that would be equivalent to applying a function to a dataframe in R. I was thinking of possibly passing a dataset to a macro.
My goal is to run a set of Proc Freq on different datasets without having to copy and paste the code each time.
Basic macro approach:
%macro dummy(dsn=); proc print data=&dsn.; run; %mend; %dummy(dsn=sashelp.class)
Or you could pass the library and set name separately if you define the macro with more parameters. Then build the combined reference with something like. &lib..&set.
Basic macro approach:
%macro dummy(dsn=); proc print data=&dsn.; run; %mend; %dummy(dsn=sashelp.class)
Or you could pass the library and set name separately if you define the macro with more parameters. Then build the combined reference with something like. &lib..&set.
Thanks. I didn't know about adding that period.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.