Sort the Soccer Teams by Number of Wins and Conference

To complete this example, you must run the Sort Data task three times: once to sort the soccer teams by number of wins; once to sort the teams in the Eastern Conference; and once to sort the teams in the Western Conference. The Sort Data task generates an output SAS data set that is saved to your default server. This data set is used later as the input data source for the List Data task. The contents of the data set change depending on which Sort Data task you run.

Step 1: Run the Sort Data Task on All of the Data

Create a Temporary Data Set

First, create a temporary data set that lists the soccer teams in the league by number of wins.
  1. Open Microsoft Word.
  2. On the SAS tab, click Tasks, and then select Datathen selectSort Data. The Choose Data dialog box appears.
  3. Click Browse. The Open Data Source dialog box appears.
  4. To open the _SoccerClub data set:
    1. In the selection pane, select Servers.
    2. From the list of servers, select your default server. In this example, the default server is SASApp.
    3. From your default server, select the SASDATA library and click Open. In this example, the library name is SASApp - SASDATA.
    4. In the SASDATA library, select the _SOCCERCLUB data set.
    The _SoccerClub data set in the Open Data Source dialog box
    Click Open. Now, the contents of the Choose Data dialog box should appear similar to the following display:
    Choose Data dialog box with the _SOCCERCLUB data set selected
    Click OK. The Sort Data task appears.
  5. In the Data panel, assign the W variable to the Sort by role. From the W sort order drop-down menu, select Descending.
    Data panel in the Sort Data task
    In the selection pane, click Results.
  6. In the Results panel, change the directory path in the Location to save output data field to default-server:WORK.SOCCERCLUB. This path is where the temporary data set is saved. You will need this information to run the List Data task later.
    For this example, the default location is SASApp:WORK.SOCCERCLUB.
    Location of the Results as displayed in the Results panel
    Click Run.
    The Sort Data task generates the SoccerClub data set in the Work library. However, there is no visual output for this task, so when the task completes, you see the following message:
    “Sort Data has completed with no visual content. You can refresh this analysis through the Manage Content dialog box.”
    Click Close.

Determine the Object Name for the Sort Data Task

To run this Sort Data task by using Visual Basic code, you need the object name that the SAS add-in assigned to this task. To determine this object name:
  1. On the SAS tab, click Manage Content. The Manage Content window appears. The Sort Data task is listed in this window.
    Sort Data task in the Manage Content window
  2. Select the Sort Data task and click Properties icon in the Manage Content window. The Sort Data Properties dialog box appears.
  3. On the General tab, remember the object name for this task. In this example, the object name is Sort_Data. You will use this object name later.
    Location of the Object Name in the Sort Data Properties dialog box
  4. Close the Sort Data Properties dialog box and the Manage Content window.

Step 2: Run the Sort Data Task on Teams in the Eastern Conference

Create a Temporary Data Set for the Eastern Conference

Now, you need to create a temporary data set for the teams in the Eastern Conference.
  1. On the SAS tab, click Tasks, and then select Datathen selectSort Data. The Choose Data dialog box appears.
  2. Select the _SOCCERCLUB data set as your input data source. In this example, the location of this set is SASApp:SASApp — SASDATA_SOCCERCLUB.
  3. Click Filter & Sort. The Modify Data Source window appears.
  4. Click the Filter tab.
  5. To create this filter:
    1. In the first drop-down menu, select Conference.
    2. In the second drop-down menu, select Equal to.
    3. In the text box, enter EC. You can also click Ellipsis button to select this value.
    Filter for the Eastern Conference Teams in the Modify Data Source window
    Click OK to apply this filter.
  6. In the Choose Data dialog box, click Details. These details show that the filter is applied to your input data source.
    Choose Data dialog box with the data source for the Eastern Conference teams
    Click OK. The Sort Data task appears.
  7. In the Data panel, assign the W variable to the Sort by role. From the W sort order drop-down menu, select Descending.
    In the selection pane, click Results.
  8. In the Results panel, change the directory path in the Location to save output data field to default-server:WORK.SOCCERCLUB. This path is where the temporary data set is saved. You will need this information to run the List Data task later.
    For this example, the default location is SASApp:WORK.SOCCERCLUB.
  9. Click Run.
    Note: If you are prompted to replace an existing data set, click Yes in the dialog box. Click Run again in the Sort Data task.
The Sort Data task overwrites the SoccerClub data set in the Work library. Now, this data set contains only the teams in the Eastern Conference.

Determine the Object Name for the Second Sort Data Task

To run this Sort Data task by using Visual Basic code, you need the object name that the SAS add-in assigned to this task. To determine this object name:
  1. On the SAS tab, click Manage Content. The Manage Content window appears. Now, there are two Sort Data tasks listed in this window.
    Manage Content window with two Sort Data tasks
  2. Select the second Sort Data task and click Properties icon in the Manage Content window. The Sort Data Properties dialog box appears.
  3. On the General tab, remember the object name for this task. In this example, the object name is Sort_Data_2. You will use this object name later.
  4. Close the Sort Data Properties dialog box and the Manage Content window.

Step 3: Run the Sort Data Task on Teams in the Western Conference

Create a Temporary Data Set for the Western Conference

Now, you need to create a temporary data set for the teams in the Western Conference.
  1. On the SAS tab, click Tasks, and then select Datathen selectSort Data. The Choose Data dialog box appears.
  2. For the input data source, select the _SOCCERCLUB data set. In this example, the path to the input data source is SASApp:SASApp — SASDATA_SOCCERCLUB.
  3. Click Filter & Sort. The Modify Data Source window appears.
  4. Click the Filter tab.
  5. To create the filter:
    1. In the first drop-down menu, select Conference.
    2. In the second drop-down menu, select Equal to.
    3. In the text box, enter WC. You can also click Ellipsis button to select this value.
    Click OK to apply this filter.
  6. In the Choose Data dialog box, click Details. These details show that the filter is applied to your input data source.
    Choose Data dialog box with data source for teams in the Western Conference
    Click OK. The Sort Data task appears.
  7. In the Sort Data task, select Data in the selection pane. In the Data panel, assign the W variable to the Sort by role. From the W sort order drop-down menu, select Descending.
  8. In the selection pane, click Results. In the Results panel, the Location to save output data field lists the directory path where this temporary data set is saved. You will need this information to run the List Data task later. For this example, change the default location to SASApp:WORK.SOCCERCLUB.
  9. Click Run.
    Note: If you are prompted to replace an existing data set, click Yes in the dialog box. Click Run again in the Sort Data task.

Determine the Object Name for the Third Sort Data Task

To run this Sort Data task by using Visual Basic code, you need the object name that the SAS add-in assigned to this task. To determine this object name:
  1. On the SAS tab, click Manage Content. The Manage Content window appears. Now, there are three Sort Data tasks listed in this window.
    Three Sort Data tasks in the Manage Content window
  2. Select the third Sort Data task and click Properties icon in the Manage Content window. The Sort Data Properties dialog box appears.
  3. On the General tab, remember the object name for this task. In this example, it is Sort_Data_3. You will use this object name later.
  4. Close the Sort Data Properties dialog box and the Manage Content window.