4Handling Dates, Strings, Numbers

So far, we have learnt how to import data and create your own data in R and SAS, along with data inspection and cleaning. Here, we will learn how to work with different kinds of data, for example, dates, strings and numbers and how to convert one data format to another in both R and SAS. This includes handling numeric data, manipulating string/character variables (i.e. by extracting a substring of a string variable), handling different types of date format and numeric calculations with dates (i.e. difference between dates) as well as categorical data.

4.1 Working with Numeric Data

Integral types represent only whole numbers (positive, negative, and zero), and nonintegral types represent numbers with both integer and fractional parts.

4.1.1 Handling Numbers in SAS

Assigning Numeric Values to Variables

We also use input to convert character to numeric variable, but in SAS we need to specify the correct type of informat as well.

COMMA ELIMINATION USING INFORMAT

Get SAS for R Users now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.