12-28-2013 09:16 AM
PUT statement is for writing information to a file (or the SAS log or output destination). It has a robust syntax that allows writing data in many ways.
PUT() function is for applying a format to a value to convert it into a character string. You can use it in expressions or an assignment statement.
12-30-2013 11:20 PM
To expand a little on Tom's explanation the PUT statement is used to write data from a SAS datastep into an object that is not a SAS dataset: usually an external file, or the SAS log or output areas. It has the ability to write text strings and formatted values of datastep variables; with the ability to tab to a position or skip to a new line or new page.
The PUT() function is used to populate a variable within a SAS dataset or view with a value derived from an existing variable or expression so it needs much less functionality. It is always used with a format specified as the second parameter, and always results in a character value whether the existing variable is numeric or character (though SAS may have to do a type conversion behind the scenes if you specify a numeric destination).
To derive a numeric value from an existing character value you need the INPUT() function with an appropriate informat. To derive a numeric value from a numeric value you would need to nest a PUT() function inside an INPUT() function, or find a specific numeric function for the transformation you require.
There are also the PUTC() and PUTN() functions which are strictly for character and numeric expressions respectively, which you need to use with %SYSFUNC() in a macro expression. They can also be used in datastep code in the case where the format needs to be selected dynamically (eg other logic in the datastep determines which format to apply).
Richard temporarily back in Oz
12-28-2013 10:57 AM
It looks like you require some sort of documentation for comprehensive understanding pf the basic concepts. I'd suggest you to google search for the free online book called step by step base sas prpgramming learning edition that has all that you need from the very basic to complex examples. Also, there is a beautiful book by author Ron Cody- SAS function by examples. I'd highly recommend referring the book.
12-30-2013 03:42 AM
If you are unable to get the free online book and some notes, Please feel free to write an email to me.
else TOM's explanation is very useful.
Uma Shanker Saini