Help using Base SAS procedures

Reg:Character or Numeric variable

Regular Contributor
Posts: 229

Reg:Character or Numeric variable


i have some variables i dont know the type they or charter or numeric.
Now i want a new variable as Type_var it should print as charater or numeric for what type of variable it is weather character or numeric
Super User
Posts: 5,884

Re: Reg:Character or Numeric variable

If you want to know how a column is defined, that information can be reached in DICTIONARY.COLUMNS (via proc sql), SASHELP.VCOLUMN or data step functions. The can assign that value to a macro variable to be used in an assignment statement.

if you want to know what type of values is stored in a character column, there's a bunch of functions that can helpful such as notdigit.

Data never sleeps
Super Contributor
Super Contributor
Posts: 3,176

Re: Reg:Character or Numeric variable

Depending on the purpose/use of a given SAS variable, you can define whether it is CHARACTER or NUMERIC type (using either a LENGTH or ATTRIB statement) or with one of multiple "import" processes, and also you should define what SAS output FORMAT is to be used to display the data.

Scott Barry
SBBWorks, Inc.

SAS Step-by-Step Programming...Working with Numeric Variables

SAS Step-by-Step Programming...Working with Character Variables

SAS 9.2 Language Concepts...SAS Variables in Expressions
Frequent Contributor
Posts: 77

Re: Reg:Character or Numeric variable

Hi Main,

With PROC CONTENTS, you can use the ODS table "Variables" to save the variables' types as a separate variable. Please look at this example:

data test;
input var1 $ var2 var3 $;
wqw 83478 360376
febifie 947604670 305035
bdhb 045670 230948

proc contents data=test;
ods output variables=var_type;

proc print data=var_type;
Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation