<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: use input and put functions to convert the type of variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709658#M26730</link>
    <description>&lt;P&gt;Is there a question here?&lt;/P&gt;
&lt;P&gt;An INFORMAT translates text into values. A&amp;nbsp; FORMAT translates values to text.&amp;nbsp; A numeric informat creates numeric values. A numeric format works on numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert from text to numbers you must use an INFORMAT.&lt;/P&gt;
&lt;P&gt;To convert from numbers to text you must use a FORMAT.&lt;/P&gt;
&lt;P&gt;To convert from text to text you can use either.&lt;/P&gt;
&lt;P&gt;To convert from numbers to numbers just use an expression.&amp;nbsp; But you could use a format to convert the number to text and then use an informat to convert the generated text back to a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jan 2021 16:44:50 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-06T16:44:50Z</dc:date>
    <item>
      <title>use input and put functions to convert the type of variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709656#M26729</link>
      <description>&lt;P&gt;'input' can return a character variable if both the input variable and format are characters. But a 'put' always returns a character. See codes below:&lt;/P&gt;
&lt;P&gt;data two;&lt;BR /&gt;age=40;&lt;BR /&gt;char1='10';&lt;BR /&gt;char2='$1,000.00';&lt;BR /&gt;char3=input(char1, $4.);&lt;BR /&gt;num4=input(char2, dollar10.2);&lt;BR /&gt;char5=put(age, 4.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 16:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709656#M26729</guid>
      <dc:creator>anming</dc:creator>
      <dc:date>2021-01-06T16:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: use input and put functions to convert the type of variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709658#M26730</link>
      <description>&lt;P&gt;Is there a question here?&lt;/P&gt;
&lt;P&gt;An INFORMAT translates text into values. A&amp;nbsp; FORMAT translates values to text.&amp;nbsp; A numeric informat creates numeric values. A numeric format works on numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert from text to numbers you must use an INFORMAT.&lt;/P&gt;
&lt;P&gt;To convert from numbers to text you must use a FORMAT.&lt;/P&gt;
&lt;P&gt;To convert from text to text you can use either.&lt;/P&gt;
&lt;P&gt;To convert from numbers to numbers just use an expression.&amp;nbsp; But you could use a format to convert the number to text and then use an informat to convert the generated text back to a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 16:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709658#M26730</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-06T16:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: use input and put functions to convert the type of variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709661#M26731</link>
      <description>&lt;P&gt;You want to be very careful specifying decimals in an informat.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;data two;
char2='$1,000';
num4=input(char2, dollar10.2);
run;
&lt;/PRE&gt;
&lt;P&gt;What do you think the value for Num4 should be? What is it when you look at the actual data?&lt;/P&gt;
&lt;P&gt;This example shows you don't need the decimal:&lt;/P&gt;
&lt;PRE&gt;data three;
char2='$1,000.25';
num4=input(char2, dollar10.);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 17:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709661#M26731</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-06T17:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: use input and put functions to convert the type of variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709662#M26732</link>
      <description>&lt;PRE&gt;char3=input(char1, $4.);&lt;BR /&gt;num4=input(char2, dollar10.2);&lt;BR /&gt;char5=put(age, 4.);&lt;/PRE&gt;
&lt;P&gt;the question is how to define 'informat' and 'format'' in these converts. According to the definition of 'informat' (tells SAS how to read the variables) all of these formats '$4., dollar 10.2 and 4.' are informats.&amp;nbsp; Then how to understand 'format' in your words:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A&amp;nbsp; FORMAT translates values to text.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;To convert from numbers to text you must use a FORMAT.&lt;/P&gt;
&lt;P&gt;To convert from text to text you can use either.&lt;/P&gt;
&lt;P&gt;what are details/principles of 'input'/'put' in terms of 'format/informat'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 17:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709662#M26732</guid>
      <dc:creator>anming</dc:creator>
      <dc:date>2021-01-06T17:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: use input and put functions to convert the type of variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709668#M26733</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/356091"&gt;@anming&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the definition of 'informat' (tells SAS how to read the variables) all of these formats '$4., dollar 10.2 and 4.' are informats.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Wrong. $4., DOLLAR10.2 are &lt;STRONG&gt;IN&lt;/STRONG&gt;formats because they are used in the&amp;nbsp;&lt;STRONG&gt;IN&lt;/STRONG&gt;PUT function, 4. is a format because it is used in a PUT function.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 17:28:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709668#M26733</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-06T17:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: use input and put functions to convert the type of variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709669#M26734</link>
      <description>&lt;P&gt;I still don't understand what you are asking.&amp;nbsp; In this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char3=input(char1, $4.);
num4=input(char2, dollar10.2);
char5=put(age, 4.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are using 2 informats and 1 format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;input(char1, $4.)&lt;/FONT&gt; is the same as you would get with &lt;FONT face="courier new,courier"&gt;left(substrn(char1,1,4))&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This function call, &lt;FONT face="courier new,courier"&gt;input(char2, dollar10.2)&amp;nbsp;&lt;/FONT&gt;, says to read the first 10 bytes of CHAR2 and interpret it as a number after removing any dollar signs, commas, or percent signs from the 10 bytes. And if the string does not have a period to mark the decimal place then assume the last two digits in the string are after the decimal place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This function call,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;put(age, 4.)&lt;/FONT&gt; , will create a string of four characters. The digits will be right aligned in the four characters (padded in front with spaces).&amp;nbsp; So if AGE=40 the result will be two spaces followed by the digit 4 and the digit 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 17:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/use-input-and-put-functions-to-convert-the-type-of-variables/m-p/709669#M26734</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-06T17:51:41Z</dc:date>
    </item>
  </channel>
</rss>

