Exampler.org SAS PYTHON HTML
SAS Introduction
SAS Abs
SAS Anydigit
SAS ASC
SAS Case Stmnt.
SAS Ceiling
SAS Change type
SAS Char
SAS CMISS
SAS Coalesc
SAS Coalescec
SAS Concatenate
SAS Constant
SAS Create Table
SAS DateTime
SAS Day
SAS Find
SAS Floor
SAS HMS
SAS Holiday
SAS HOUR
SAS Import
SAS Informats
SAS Inobs
SAS Input Stmt.
SAS Int
SAS INTNX
SAS Length
SAS Libname
SAS Loops
SAS Minute
SAS Month
SAS MDY
SAS NMISS
SAS Notdigit
SAS Lowercase
SAS Outobs
SAS Put Stmt.
SAS Rename
SAS Round
SAS Scan
SAS Substr
SAS Sum
SAS STNAME
SAS STNAMEL
SAS Time
SAS Trunc
SAS Uppercase
SAS Week
SAS Year
SAS Financial Functions
SAS Compound

SAS - Input (Change Datatype)

What is it?


Input Example:


 Input Example:



libname ABCDEFGH postgres server="Server_Address.com" port=5432 user=kevin password="P@ssW0rd" database=DBName schema=SchemaName;


Data work.my_data_file;

  set my_data_file;
    modified_id = input(id, 6.);
run;

proc
  print data=my_data_file;
run;






What's happening in the script above?

  • The script is connecting to the postgres database/datasource
  • Data step is creating the work.my_data_file temporary dataset
  • The SET statement reads variables and observations from the input set
  • creates a variable (modified_id) which is the modified result of the Input section whereby the id is converted to numeric
  • The remaining lines prints out the results



Informat Examples:

Input Informat Output Description
08/11/2003 mmddyyyy10.0 15928 The number of days since YEARCUTOFF option (yearcutoff=1920)
$13,203 Comma10.2 13203.00 Drops dollar sign and commas
12345 $CHAR6. 12345 The value will store leading blanks if they exist
12345 $6. 12345 Numeric value 6 characters long, no decimal places
1327034.13 Dollar10.2 $1,327,034.13 Adds dollar sign and commas
0000012345 z10. 0000012345 Keeps leading zeros

Connect via LinkedIn

Kevin Regan

Have an article, idea, found a typo, want to contribute? Shoot me an email Here


Below are links to some Udemy Data Science Courses. I've been using Udemy for a number of years now, and I've found their courses super helpful, maybe you will also.