{
  "name": "PROC SORT directives: ordering, replacement and retention",
  "description": "Original compilation of selected PROC SORT directives by their effect on ordering, input replacement and record retention. Compiled from the SAS Institute Base SAS 9.4 Procedures Guide, Seventh Edition; page references identify the supporting sections. These are documented behaviors for ordinary SAS datasets, not measured runtime results.",
  "page": "https://casrai.org/guides/proc-sort-sas",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-19T15:25:00Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Directive",
      "unit": "",
      "description": ""
    },
    {
      "name": "Purpose",
      "unit": "",
      "description": ""
    },
    {
      "name": "Effect or condition to inspect",
      "unit": "",
      "description": ""
    },
    {
      "name": "SAS manual printed pages",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Directive": "OUT= with a different dataset name",
      "Purpose": "Create a separate sorted result",
      "Effect or condition to inspect": "Preserves input; omitting OUT= or naming the input again allows replacement.",
      "SAS manual printed pages": "2424–2425; 2435"
    },
    {
      "Directive": "BY variable list",
      "Purpose": "Define ordered keys",
      "Effect or condition to inspect": "Ascending by default; each later variable orders ties on preceding variables. Does not itself remove observations.",
      "SAS manual printed pages": "2429; 2422"
    },
    {
      "Directive": "DESCENDING before a BY variable",
      "Purpose": "Reverse one key direction",
      "Effect or condition to inspect": "Affects only the immediately following variable, not the complete BY list.",
      "SAS manual printed pages": "2429"
    },
    {
      "Directive": "NODUPKEY",
      "Purpose": "Retain one observation per complete BY key",
      "Effect or condition to inspect": "Different non-key values can be excluded; complete-row uniqueness requires all variables in the key.",
      "SAS manual printed pages": "2422–2423"
    },
    {
      "Directive": "EQUALS",
      "Purpose": "Preserve input-relative order of tied BY values",
      "Effect or condition to inspect": "Supports predictable first-record retention for Base SAS engine input sorted by SAS; cannot cure unpredictable database retrieval.",
      "SAS manual printed pages": "2421–2423; 2426"
    },
    {
      "Directive": "DUPOUT= with NODUPKEY",
      "Purpose": "Save excluded duplicate-key observations",
      "Effect or condition to inspect": "Provides a separate dataset for observations removed by the duplicate-key operation.",
      "SAS manual printed pages": "2420–2421; 2424"
    }
  ],
  "sources": [
    {
      "title": "SAS Institute: Base SAS 9.4 Procedures Guide, Seventh Edition, SORT Procedure",
      "url": "https://documentation.sas.com/api/docsets/proc/9.4/content/proc.pdf?locale=en",
      "accessed": "2026-11-16"
    }
  ]
}