10-04-2016 01:12 AM
10-04-2016 01:59 AM
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.
10-04-2016 02:25 AM
10-04-2016 03:28 AM
Post the code and describe which part of it should be parameterized.
10-05-2016 01:43 AM
10-05-2016 01:54 AM
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;
10-05-2016 03:50 AM
10-05-2016 04:22 AM
Which parts of the code need to be parameterized?
10-05-2016 05:04 AM
Do you want to change the variable that's used, or do you want to compare with a specific value?
10-05-2016 05:07 AM
10-05-2016 05:14 AM
But the max crdate is always used. If the variable name doesn't change that doesn't need to be parametrized.
Post a few different versions of what the code would be for us to understand what you need a macro for.
10-05-2016 06:21 AM
10-05-2016 06:49 AM
%macro your_macro_name(memname); *here comes your code; *example; where memname = "&memname"; *further code; %mend;
10-04-2016 04:26 AM
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;