2
votes

SAS documentation defines the input and put functions as:

Input function: Returns the value that is produced when SAS converts an expression using the specified informat

Put function: Returns a value using a specified format.

So the input function takes the variable and an informat as arguments, while the put functions takes the variable and a format as arguments, right?

If that is the case, why is the input function used to convert a variable from character to numeric, while the put function is used to convert a variable from numeric to character?

Are the input and put functions more tied to informats and formats, respectively, as opposed to character to numeric and numeric to character conversions, respectively?

Also, what is the difference between the input and put functions and the input and put statements?

1
I think your last line should be a separate question. The answer to that question is in the documentation.Reeza
Also, it's not quite as straightforward as you've stated. Here's a SAS blog post that illustrates the intricacies of the functions. blogs.sas.com/content/sgf/2015/05/01/…Reeza

1 Answers

0
votes

The last question answers the first one. It is easiest to think of the PUT() function and INPUT() function in terms of how the PUT and INPUT statements work.

The PUT statement is for printing data into a text file report. You can print numeric or character variables but you are always writing character strings. The INPUT statement is for reading data from a text file. You can read into numeric or character variables but you are always reading from character strings.