- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes it is much better and easy
thanks a lot sir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
same result appear as you code in macros
thanks a lot