BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
whs278
Quartz | Level 8

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.  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

whs278
Quartz | Level 8

Thanks.  I didn't know about adding that period.  

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3252 views
  • 0 likes
  • 2 in conversation