string to numeric and adjust width

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

statsgirl
Posts: 16
Joined: Sat Aug 04, 2012 1:52 am

string to numeric and adjust width

Postby statsgirl » Mon Oct 08, 2012 10:09 pm

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?
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

Re: string to numeric and adjust width

Postby Penguin_Knight » Tue Oct 09, 2012 12:18 am

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 .

Who is online

Users browsing this forum: No registered users and 1 guest

cron