SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 43203: Dynamic prompt values appear in sorted order instead of retaining data order when the "Use default sort order" option is selected

DetailsAboutRate It

When a dynamic prompt is defined for use in a SAS® Stored Process, the Sort order field for the prompt contains the following choices:

  • Use default sort order
  • Ascending by formatted value
  • Descending by formatted value
  • Ascending by unformatted value
  • Descending by unformatted value

Some prompts might ignore the Use default sort order option and present the prompt values in ascending sorted order, instead of retaining the order of the variable values in the data source.

Consider the following example, which illustrates the problem:

A data source contains two variables, RESPONSE and DESCRIPTION

response    description

   NA       Not Applicable
   1        Strongly Agree
   2        Agree
   3        Neither Agree Nor Disagree
   4        Disagree
   5        Strongly Disagree
   ?        Did not respond

A dynamic prompt is created using the variable RESPONSE for the Unformatted Values column, and using variable DESCRIPTION for the Formatted (Displayed) Values column. Use default sort order is selected for the prompt to retain the order of the values in the data source.

The prompt ignores the Use default sort order option and presents the DESCRIPTION values in ascending sorted order, rather than in the order the values appear in the data source:

    Agree
    Did Not Respond
    Disagree
    Neither Agree Nor Disagree
    Not Applicable
    Strongly Agree
    Strongly Disagree

To circumvent this problem, perform the following steps:

  1. Create a new variable in the data source to establish the desired order for the values of the prompt variable. In the above example, numeric values 1-7 or character values A-G could be used:
            if response="NA" then sort="A"; 
            else if response="1" then sort="B";
            
  2. ...and so on.

  3. Designate the new variable (SORT) for the Unformatted Values column of the dynamic prompt, and leave the variable (DESCRIPTION) as the Formatted (Displayed) Values column of the dynamic prompt. Then, select the Ascending by unformatted value option for the Sort order.
  4. Modify the underlying SAS Stored Process code to reference the newly created variable values for input parameter processing:
            if &prompt="B" then do;

    instead of...

            if &prompt="1" then do;
            
  5. ...and so on.



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemSAS Integration Technologiesz/OS9.2 TS2M09.3 TS1M2
Microsoft® Windows® for 64-Bit Itanium-based Systems9.2 TS2M09.3 TS1M2
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.2 TS2M09.3 TS1M2
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.2 TS2M09.3 TS1M2
Microsoft Windows XP 64-bit Edition9.2 TS2M09.3 TS1M2
Microsoft® Windows® for x649.2 TS2M09.3 TS1M2
Microsoft Windows Server 2003 Datacenter Edition9.2 TS2M09.3 TS1M2
Microsoft Windows Server 2003 Enterprise Edition9.2 TS2M09.3 TS1M2
Microsoft Windows Server 2003 Standard Edition9.2 TS2M09.3 TS1M2
Microsoft Windows Server 2003 for x649.2 TS2M09.3 TS1M2
Microsoft Windows Server 2008 for x649.2 TS2M09.3 TS1M2
Microsoft Windows XP Professional9.2 TS2M09.3 TS1M2
Windows Vista9.2 TS2M09.3 TS1M2
Windows Vista for x649.2 TS2M09.3 TS1M2
64-bit Enabled AIX9.2 TS2M09.3 TS1M2
64-bit Enabled HP-UX9.2 TS2M09.3 TS1M2
64-bit Enabled Solaris9.2 TS2M09.3 TS1M2
HP-UX IPF9.2 TS2M09.3 TS1M2
Linux9.2 TS2M09.3 TS1M2
Linux for x649.2 TS2M09.3 TS1M2
OpenVMS on HP Integrity9.2 TS2M09.3 TS1M2
Solaris for x649.2 TS2M09.3 TS1M2
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.