SAS: PUT VS. INPUT

- 1 min

Overview

When it comes to converting data type or variable type in SAS, it is always challenging to figure out when to use PUT and when to use INPUT.

The PUT function can be applied to a character or numeric input, but the output of the Put function is always character.

The INPUT function can only be applied to a character target, but the output can be character or numeric.

“In the old, old days” data sources and destinations were usually text.

INPUT statements, and INFORMATs, convert external “text files” into either SAS® character or numeric variables in a SAS data set– converting from “text only” to two types of variables

PUT statements, and FORMATs, are used to convert SAS character and numeric variables “into character” – two types into one.

Illustration

A. PUT() converts character variable to another character variable.
B. PUT() converts numeric variable to a character variable with numeric value.
C. PUT() converts character variable with a user defined format to another character variable.

D. INPUT() converts character variable with numeric value and informat to a numeric variable.
E. INPUT() converts character variable with numeric value and informat to a character variable.
F. INPUT() converts character variable with numeric value and informat to a numeric variable.


Reference

Zhijian Liu

Zhijian Liu

A foodaholic

comments powered by Disqus
rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora