Step 6: Run the Task to View the Generated SAS Code and Resulting Output Data Set

Now, you compare the results and generated SAS code when the Same name? check box is selected and when this check box is not selected.

The Same Name Check Box Is Selected

If you select the Same name? check box in the user interface and then run the task, the resulting output data set contains the same number of variables as the input data set. Also, the names of the variables in the output data set are the same as the names in the input data set. In this example, the character variable in the input data set has been dropped, and a new numeric variable with the same name has been added to the output data set.
To view this result:
  1. On the tab that contains your CTM code, click Run Icon to generate the user interface for the task.
  2. In the user interface, select these options:
    • For the input data source, select WORK.CHARACTER.
      Note: If your SAS Studio session has timed out since you created this data set, this data set is no longer available from the temporary Work library. You must re-create this data set to continue. To re-create the data set, see Create the Example Data Set.
    • For the character variable to convert, select Age.
    • Select the Same name? check box.
    • Verify that 10 is in the Informat width box.
      Here is the updated user interface:
      Example of Using the Same Name Check Box
      The generated SAS code appears on the Code tab.
      data WORK.Test;
         set WORK.CHARACTER(rename=Age=Age_old);
         Age=input (Age_old, BEST10.);
         drop Age_old;
      run;
      
      Note: The BEST10 informat was defined using the returnValue attribute and the defaultValue attribute in these two lines of code in the metadata:
      <Option name="numericChoice" inputType="string" 
         returnValue="BEST">Numeric</Option>
      <Option name="informatLength" inputType="numbertext" minValue="1"
            defaultValue="10">Informat width:</Option>
  3. Click Run Icon to run the task.
The results appear on the OUTPUT DATA tab. The output data set is called Work.Test. It contains the same three variables (Name, Enroll_Date, and Age) as the input data set. However, Age is now a numeric variable instead of a character variable.
Results When Same Name Check Box Is Selected

The Same Name Check Box Is Not Selected

When you run the task and the Same name? check box is not selected, the resulting data set includes the existing character variable and a new numeric variable called variable-name_new.
To view this result:
  1. Return to the DATA tab in the user interface and clear the Same name? check box.
    Here is the updated user interface:
    Task Interface with the Same Name Check Box Not Selected
    The generated SAS code appears on the Code tab.
    data WORK.TEST;
       set WORK.CHARACTER;
       Age_new=input(Age, BEST10.);
    run;
  2. Click Run Icon to run the task.
The results appear on the OUTPUT DATA tab. The resulting output data set includes all of the variables from the input data set and a new variable called variable-name_new. In this example, the results contain both the Age and Age_new variables. Age is a character variable, and Age_new is a numeric variable.
Output Data Set with Both Age and Age_new Variables
You can now close the task.