37.0 SORT Command The SORT command does an incore sort of the data matrix. All variables are sorted against variables listed on the BY statement. Form of command. B34SEXEC SORT$ BY var1 var2 $ B34SEEND$ SORT sentence options. ASCENDING - Sorts in ascending order. This is the default. DESCENDING - Sorts in descending order. The BY sentence is required. The user specifies the order of the sort by the order of the variables listed on the BY sentence. The sort is in terms of ascending, with the first variable listed sorted first. Example 1. simple sort. b34sexec data nohead noob=6$ input x y z$ datacards$ 11 33 55 22 99 99 33 23 14 01 44 88 01 33 77 22 24 25 b34sreturn$ b34seend$ b34sexec sort$ by x$ b34srun$ produces a data file ordered as: 01 44 88 01 33 77 11 33 55 22 24 25 22 99 99 33 23 14 If the BY statement was by x y$ the file would be 01 33 77 01 44 88 11 33 55 22 24 25 22 99 99 33 23 14 Example # 2 Sample two variable sort from SAS /$ sample sort test from SAS b34sexec data $ input name number phone room start$ character name$ datacards$ Rebeccah 11 424 112 1 Carol 4 450 112 2 Louise 9 409 110 3 Gina 6 474 110 4 Mimi 10 410 109 5 Alice 1 411 106 6 Brenda 3 414 105 7 David 5 438 141 8 Betty 2 464 141 9 Holly 8 466 140 10 Gretel 7 465 140 11 b34sreturn$ b34srun$ b34sexec list$ b34srun$ b34sexec sort$ by name$ b34srun$ b34sexec list$ b34srun$ b34sexec sort$ by start$ b34srun$ b34sexec sort$ by room name$ b34srun$ b34sexec list$ b34srun$