|Doing More with SAS/ASSIST Software|
Sometimes numeric data is stored in columns that have
data types. In order to do calculations with this numeric data, you must convert
the character columns to numeric. You can use Subset/Copy
on the Data Management menu to change a column from a character to a numeric
format. In this section, you convert the character column DAY, which is found
in the ORANGES table, to a numeric column. The value in the character column
DAY is a (character) number from
For additional information on changing columns from character to numeric and vice versa, refer to the PUT and INPUT functions and formats and informats in SAS Language Reference: Dictionary.
Subset or Copy A Table Window
Output Table or View Window
ORANGNUMin the Table/View field.
ORANGNUM is a new table that you create to contain the new numeric column DAYNUM. By leaving the defaults of Temporary and Table selected, you create a temporary table in the WORK library, which is deleted when you exit the SAS System. An indicator next to Temporary and Table shows that these items are selected.
Define or Modify a Column Window
You use this window to define the new columns that you are adding to the output table.
DAYNUMas the name of the column.
Leave the Type as
Enter Numeric Expression Window
You use this window to build an expression that is used to define the new column.
Select Type of Function Window
Select Data Window for Character Functions
Specify Arguments to a Function Window
You select INPUT(c,ifmt) because the source column DAY is character.
In the Value for parameter
field next to INFORM, type
DAY in the CHAR parameter field because
you want to use the values of the DAY column in the ORANGES table as the source
for the DAYNUM column that you are creating.
The informat 2.1 is used in this example so you can check to see that this task completed correctly. However, you can use any valid informat. In this example, if you select a format such as 1., the only indication that the new column is numeric is that it is right justified when displayed in the FSVIEW window. However, if you use 2.1 as an informat, the new column DAYNUM is right justified and converted to display tenths.
Follow this selection path:
The new DAYNUM column is created, and the data is copied to the output table. An FSVIEW window appears with the data in the output table.
New DAYNUM Column
To confirm that the column is numeric, browse the properties of the table. See Altering the Properties of a SAS Table for more information.
You can use the above procedure to convert character dates and times to SAS date and time values. In the Specify Arguments to a Function window, specify an appropriate date, time, or datetime informat for INFORM. For example, if you have a column of character dates in the form 05MAR1999, use the DATE9. informat. In the Define or Modify a Column window, you might want to specify an appropriate date, time, or datetime format by selecting Format.
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.