As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Macro Ordinal

From sasCommunity
Jump to: navigation, search

Macro Ordinal is available on Macro_Loops_with_Dates.

It adds a suffix to an integer.


1  /* name: ordinal-test
2     ***/
3   %put ordinal of 1:%ordinal(1)
4        ordinal of 2:%ordinal(2)
5        ordinal of 3:%ordinal(3)
6        ordinal of 4:%ordinal(4)
7               ;
ordinal of 1:1st      ordinal of 2:2nd      ordinal of 3:3rd      ordinal of 4:4th

8   %Macro doloop(start=0, stop=14, step=1);
9   %do N = &start %to &stop %by &step.;
10      %put n=&N: %ordinal(&n);
11      %end;
12      %mend;
13  %doloop()
n=0: 0th
n=1: 1st
n=2: 2nd
n=3: 3rd
n=4: 4th
n=5: 5th
n=6: 6th
n=7: 7th
n=8: 8th
n=9: 9th
n=10: 10th
n=11: 11th
n=12: 12th
n=13: 13th
n=14: 14th

--Ronald_J._Fehd macro.maven == the radical programmer