Put function in sas

Put function in sas

Posted: SoftDoc Date: 04.06.2017

Can someone explain what the use of the Put function?

put function in sas

I thought it converts numeric data values to character data values. How does it convert a numeric to a character? The source argument can be character or numeric.

This argument must be the name of a format with a period and optional width and decimal specifications, not a character constant, variable, or expression.

Demand lazuxyderonav.web.fc2.com: Are you Planning By Exception?

By default, if the source is numeric, the resulting string is right aligned, and if the source is character, the result is left aligned. To override the default alignment, you can add an alignment specification to a format:.

Log transformations: How to handle negative data values? - The DO Loop

If the PUT function returns a value to a variable that has not yet been assigned a length, by default the variable length is determined by the width of the format. Use PUT to convert a numeric value to a character valu e. The PUT function has no effect on which formats are used in PUT statements or which formats are assigned to variables in data sets.

You cannot use the PUT function to change the type of a variable in a data set from numeric to character. A simple Put statement writes data to the default output destination log or destination specified in a File statement.

put function in sas

If you run Proc Contents or use the SAS Explorer to examine the Junk data set you will see that NewX is a charater variable. If put somevariablename, UsingThisFormat.

It can create a different character value from a character depending on the nature of the specific format used. The PUT function applies a format to a value. Since formats are used for displaying values in output they always return character strings. This is similar to using the PUT statement to write out data.

You can apply a numeric format to a numeric value or apply a character format to a character value, but either way the result is a character string.

Converting variable types—use PUT() or INPUT()? - SAS Users

The INPUT function can by used to convert a character string to either a numeric or character value based on the informat that is used. This is similar to reading data using the INPUT statement.

Of course the most frequent use of the PUT function is to convert a numeric value to a character string to create a new character variable. You may find this SAS Sample note helpful too DATA Step, Macro, Functions and more.

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. Reply Topic Options Subscribe to RSS Feed Mark Topic as New Mark Topic as Read Float this Topic for Current User Bookmark Subscribe Printer Friendly Page. Options Mark as New Bookmark Subscribe Subscribe to RSS Feed Highlight Print Email to a Friend Report Inappropriate Content. Arguments source identifies the constant, variable, or expression whose value you want to reformat.

To override the default alignment, you can add an alignment specification to a format: That is, if the source is character, the format name must begin with a dollar sign, but if the source is numeric, the format name must not begin with a dollar sign.

Message 1 of 6 1, Views. Message 2 of 6 1, Views.

The Put function has two different behaviors depending on use. The result is character. You can use put in comparison: If you want t.

Tips:Aligning with a Put Function - sasCommunity

Message 3 of 6 1, Views. Message 4 of 6 1, Views. Here's an example of the PUT function to perform these conversions: Message 5 of 6 1, Views. Message 6 of 6 1, Views. PUT source , format.

inserted by FC2 system