BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
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
3 REPLIES 3
LinusH
Tourmaline | Level 20
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
statsplank
Calcite | Level 5
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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 615 views
  • 0 likes
  • 4 in conversation