following data step extracting data from 5th observation to 10th observation from datafile
data newfile;
set datafile;
if _N_ in (5,6,7,8,9,10,11,12,13,14) then output;
run;
I am trying same output using macros but it could not give result
I use %obs()
any one can help me on this
An example for dynamic code expanded from the current one:
%macro mymac(fobs,lobs);
data newfile;
set datafile (firstobs=&fobs. obs=&lobs.);
run;
%mend;
%mymac(5,14)
The "action" is still in the data step, but the parameters are now dynamic.
Much better do do it with the respective dataset options:
data newfile;
set datafile (firstobs=5 obs=14);
run;
You do not do data manipulation with the macro preprocessor. The macro preprocessor is for creating dynamic code. So unless there is something in this code that you want to make dynamic, there is no need for macro processing.
Yes it is much better and easy
thanks a lot sir.
An example for dynamic code expanded from the current one:
%macro mymac(fobs,lobs);
data newfile;
set datafile (firstobs=&fobs. obs=&lobs.);
run;
%mend;
%mymac(5,14)
The "action" is still in the data step, but the parameters are now dynamic.
same result appear as you code in macros
thanks a lot
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!