08-19-2013 05:31 AM
A macro that will sort a dataset?
%Macro sorter(dsn, var);
proc sort data=&dsn.;
will sort sample_dataset by the variable age.
08-19-2013 06:29 AM
Good question to start with Murray.
Have seen a lot of people starting to learn SAS calling everything a "macro".
Not been aware of te datastep / procedures / sas-macro / scl , metadata and may other artifacts used ad code/programming tools.
08-20-2013 03:56 AM
SAS macros is a whole programming language, and teaching a such is not suitable in a forum.
I suggest that you spend some time with the documentation, and potentially read some papers (i.e. from SAS Global Forum), and potentially attend to some training (physical or online).
08-20-2013 05:03 AM
Macros allow you to automatically submit programs based on arbitrary requirements.
If I have to sort 100 datasets in the same way, to save time I would write the 'sorter' macro as above, and call it with reference to my 100 datasets, this saves a lot of copying and pasting, as the macro prossesor does that for us.
For a rounded education on macros I would reccomend the SAS Certification Prep Guide:: Advanced Programming for SAS 9, Third Edition. About a thir dof this book looks exclusively at the way macros work.