When you need to write a macro you first need working code and then you convert it.
Do you have working code that needs to be turned into a macro? And since this is a trivial task why do you need a macro? Which parts are dynamic in nature. Please be more explicit in your questions.
Post the code and describe which part of it should be parameterized.
Use the having clause and the max() summary function in SQL:
proc sql; select * from dictionary.tables where libname = 'common' having crdate = max(crdate); quit;
Do you want to change the variable that's used, or do you want to compare with a specific value?
%macro your_macro_name(memname); *here comes your code; *example; where memname = "&memname"; *further code; %mend;
Post code, and examples to clarify the question. As for your problem, why do you need a macro?
/* Test data */
proc sql; create table a (a char(2)); quit; data b; b=1; run; /* This is the code */ proc sort data=sashelp.vtable out=inter; by memname; where libname="WORK" and nobs > 0; run; data _null_; set inter (obs=1); call execute(cats('data want; set work.',memname,' (obs=1); run;')); run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.