BookmarkSubscribeRSS Feed
SushilKumar
Calcite | Level 5

Hi ,

Could any one help me Out that how to use Proc sort in macros.

6 REPLIES 6
Murray_Court
Quartz | Level 8

A macro that will sort a dataset?

%Macro sorter(dsn, var);

proc sort data=&dsn.;

by &var.;

run;

%mend;

%sorter(sample_dataset, age);

will sort sample_dataset by the variable age.

jakarman
Barite | Level 11

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.

---->-- ja karman --<-----
SushilKumar
Calcite | Level 5

Thank you murray

Could you explain me how it works, because i new to sas macros

LinusH
Tourmaline | Level 20

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).

Data never sleeps
SushilKumar
Calcite | Level 5

thank you

Murray_Court
Quartz | Level 8

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 6171 views
  • 0 likes
  • 4 in conversation