Page 1 of 1

string to numeric and adjust width

Posted: Mon Oct 08, 2012 10:09 pm
by statsgirl
What is the syntax for converting a string variable to a numeric variable? Once it is numeric, what is the syntax to set the variable width?

Re: string to numeric and adjust width

Posted: Tue Oct 09, 2012 12:18 am
by Penguin_Knight
Suppose your string variable is called v1 and the new numeric variable is called v2:

Code: Select all

recode v1 (convert) into v2 .
execute.
To change v2 into 12 digits long with 3 as decimal:

Code: Select all

formats v2 (f12.3) .
execute .