Help using Base SAS procedures

Reg:Character or Numeric variable

Reply
Regular Contributor
Posts: 229

Reg:Character or Numeric variable

Hi

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,255

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.

/Linus
Data never sleeps
Super Contributor
Super Contributor
Posts: 3,174

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
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304311.htm

SAS Step-by-Step Programming...Working with Character Variables
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304318.htm

SAS 9.2 Language Concepts...SAS Variables in Expressions
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000780416.htm
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 $;
datalines;
wqw 83478 360376
febifie 947604670 305035
bdhb 045670 230948
;
run;

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

proc print data=var_type;
run;
Ask a Question
Discussion stats
  • 3 replies
  • 101 views
  • 0 likes
  • 4 in conversation