Creating and Editing Data

Example: Creating a Small Data Set

The data in this example are quarterly sales for two employees, June and Bob.


Create a new data set by choosing File \blacktriangleright\,New \blacktriangleright\,Data Set from the main menu.

A dialog box prompts you for the name of the first variable. The first variable will contain the name of the sales staff. Fill in the dialog box (shown in Figure 3.1) as described in the following steps.


Type Employee in the Name field.

The contents of this box must be a valid SAS variable name as specified in the section "Adding Variables".


In the Type field, select Character.

Click OK.



ugdnnewdataset.png (4895 bytes)

Figure 3.1: Creating a Character Variable

The second variable will indicate the quarter of the financial year for which sales are recorded. The only valid values for this numeric variable are the discrete integers 1 - 4. Thus you will create this next variable as a nominal variable.


Create a new variable by choosing Edit \blacktriangleright\,Variables \blacktriangleright\,New Variable from the main menu.

Fill in the dialog box (shown in Figure 3.2) as described in the following steps.


Type Quarter in the Name field.

Select Nominal from the Measure Level menu.

Click OK.



ugdnquartervar.png (5035 bytes)

Figure 3.2: Creating a Nominal Numeric Variable

The third variable will contain the revenue, in thousands of dollars, for each salesperson for each financial quarter.


Create a third variable by choosing Edit \blacktriangleright\,Variables \blacktriangleright\,New Variable from the main menu.

Fill in the dialog box (shown in Figure 3.3) as described in the following steps.


Type Sales in the Name field.

In the Label field, type Sales (Thousands).

In the Format list, select DOLLAR. Type 4 in the W field.


Click OK.



ugdnsalesvar.png (5255 bytes)

Figure 3.3: Creating a Numeric Variable with a Format


Now you can enter observations for each variable. Note that the new data set was created with one observation containing a missing value for each variable. The first observation should be typed in the first row; subsequent observations are added as you enter them.

Entering data in the data table row marked with an asterisk (\ding {83} ) creates a new observation. When you are entering (or editing) data, the ENTER key takes you down to the next observation. The TAB key moves the active cell to the right, whereas holding down the SHIFT key and pressing TAB moves the active cell to the left. You can also use the keyboard arrow keys to navigate the cells of the data table.


Enter the data shown in Table 3.1.
Table 3.1: Sample Data
Employee Quarter Sales
June 1 34
Bob 1 29
June 2 24
Bob 2 18
June 3 28
Bob 3 25
June 4 45
Bob 4 32

Note: When you enter the data for the Sales variable, do not type the dollar sign. The actual data is \{34, 29, ... , 32\}, but because the variable has a DOLLAR4. format, the data table displays a dollar sign in each cell.

The data table looks like the table in Figure 3.4.

ugdndatasetcomplete.png (5712 bytes)

Figure 3.4: New Data Set

At this point you can save your data.


Select File \blacktriangleright\,Save as File from the main menu. Navigate to the Data Sets subdirectory of your personal files directory and save the file as sales.sas7bdat.

Note: The default location of the personal files directory is given in the section "The Personal Files Directory". When you want to open your data later, you can select File \blacktriangleright\,Open \blacktriangleright\,File from the main menu. The dialog box that appears has a button near the bottom that says Go to Personal Files directory. For this reason, it is convenient to save data in your personal files directory.

Previous Page | Next Page | Top of Page