• Home
  • About Dominick A. Leone
    • Homepage
  • SAS Code
  • Pubfacts | Pubmed listing
  • ResearcherID
  • ORCID
  • SciENcv
  • NCBI Bibliography

Dominick A. Leone

Dominick A. Leone

Tag Archives: SAS

Changing from a character variable into numeric in SAS

26 Wednesday Nov 2014

Posted by Dominick A. Leone in Uncategorized

≈ Leave a comment

Tags

character, Informatics, numeric, recoding, SAS

Changes must be in a data-step.

If you are recoding an existing variable, you may need to come back in and rename the new variable (NUMERIC_var) back to the original (CHAR_var) name so as to be consistent with your variable dictionary.

The Input function in SAS will take the form: “Input (variable, format).” Specify the numeric format that you want to create, but for dates this will also depend on the character contents. If you are capturing dates, then “2014-01” is a different than “01-20-2014.”


EXAMPLE

DATA mydataset_NEW;

SET mydataset;

NUMERIC_var = Input ( CHAR_var, 3.0);  /* for simple conversion */

DATE_var = Input ( CHAR_var, date9.); /* for dates */

.

.

.

RUN;

Advertisement

Software

  • R Website Beginning page where you can find everything related to R: downloads, extensions, information, and general help

Software

  • R Website

ResearcherID

Blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • Dominick A. Leone
    • Already have a WordPress.com account? Log in now.
    • Dominick A. Leone
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar