<?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: Why use the put function if the variables are Character with no conversion? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963116#M375269</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;BasinGroup=put(Basin, $region.); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT writes the value of BASIN using the $REGION format and assigns this value to variable BASINGROUP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if BASIN contains value 'NA' then BasinGroup contains the value 'Atlantic'.&amp;nbsp;I don't know what "no conversion" in your title means; here 'NA' is, in a manner of speaking, converted to 'Atlantic'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the other code, where there is no PUT statement, the format $REGION is applied to variable BASINGROUP, and so the value 'NA' remains the value, but you see 'Atlantic'. (Please note that in the other code with the PUT statement, BASINGROUP has value 'Atlantic') That's what formats do, they change the appearance, but do not change the underlying value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, why use PUT? To change the actual value; using a format does not change the actual value, formats change the appearance of the value. This can make a difference in sorting, if you want a specific sort order, the two possibilities could sort differently. There are probably other reasons as well, but without knowing the real use of this data (because this is a contrived example), I can't be more specific.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post code inside a code box as I did above; please click on the "little running man" icon to open a code box.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Apr 2025 14:34:35 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-04-01T14:34:35Z</dc:date>
    <item>
      <title>Why use the put function if the variables are Character with no conversion?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963115#M375268</link>
      <description>&lt;P&gt;This is from the DATA Manipulation Course 9.4 Base Programming.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please explain the use of the put function in this activity.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Open&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;p204a03.sas&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;activities&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;folder and perform the following tasks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="q1" class="question"&gt;
&lt;UL&gt;
&lt;LI value="1"&gt;
&lt;DIV&gt;
&lt;DIV&gt;Activity 4.03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; 1) Review the PROC FORMAT step that creates the&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;$REGION format that assigns basin codes into&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;groups. Highlight the step and run the selected&amp;nbsp; &amp;nbsp; &amp;nbsp;*;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;code.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; 2) Notice the DATA step includes IF-THEN/ELSE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;statements to create a new column named BasinGroup. *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; 3) Delete the IF-THEN/ELSE statements and replace it&amp;nbsp; &amp;nbsp;*;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;with an assignment statement to create the&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;BasinGroup column. Use the PUT function with Basin&amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;as the first argument and $REGION. as the second&amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;argument.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; 4) Highlight the DATA and PROC MEANS steps and run the *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;selected code. How many BasinGroup values are in&amp;nbsp; &amp;nbsp; *;&lt;/DIV&gt;
&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;the summary report?&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*;&lt;/DIV&gt;
&lt;DIV&gt;***********************************************************;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;proc format;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; value $region 'NA'='Atlantic'&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'WP','EP','SP'='Pacific'&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'NI','SI'='Indian'&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ' '='Missing'&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; other='Unknown';&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data storm_summary;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; set pg2.storm_summary;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Basin=upcase(Basin);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; BasinGroup=Basin;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; format BasinGroup $region.;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp;*or */&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data storm_summary;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; set pg2.storm_summary;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Basin=upcase(Basin);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt; BasinGroup=put(Basin, $region.);&amp;nbsp;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp; &amp;nbsp;*Delete the IF-THEN/ELSE statements and replace them with an assignment statement; */&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp; &amp;nbsp;if Basin='NA' then BasinGroup='Atlantic'; */&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp; &amp;nbsp;else if Basin in ('WP','EP','SP') then BasinGroup='Pacific'; */&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp; &amp;nbsp;else if Basin in ('NI','SI') then BasinGroup='Indian'; */&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp; &amp;nbsp;else if Basin=' ' then BasinGroup='Missing'; */&lt;/DIV&gt;
&lt;DIV&gt;/*&amp;nbsp; &amp;nbsp; &amp;nbsp;else BasinGroup='Unknown'; */&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;proc means data=storm_summary maxdec=1;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; class BasinGroup;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; var MaxWindMPH MinPressure;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 13:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963115#M375268</guid>
      <dc:creator>hmlong25</dc:creator>
      <dc:date>2025-04-01T13:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why use the put function if the variables are Character with no conversion?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963116#M375269</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;BasinGroup=put(Basin, $region.); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT writes the value of BASIN using the $REGION format and assigns this value to variable BASINGROUP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if BASIN contains value 'NA' then BasinGroup contains the value 'Atlantic'.&amp;nbsp;I don't know what "no conversion" in your title means; here 'NA' is, in a manner of speaking, converted to 'Atlantic'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the other code, where there is no PUT statement, the format $REGION is applied to variable BASINGROUP, and so the value 'NA' remains the value, but you see 'Atlantic'. (Please note that in the other code with the PUT statement, BASINGROUP has value 'Atlantic') That's what formats do, they change the appearance, but do not change the underlying value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, why use PUT? To change the actual value; using a format does not change the actual value, formats change the appearance of the value. This can make a difference in sorting, if you want a specific sort order, the two possibilities could sort differently. There are probably other reasons as well, but without knowing the real use of this data (because this is a contrived example), I can't be more specific.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post code inside a code box as I did above; please click on the "little running man" icon to open a code box.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 14:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963116#M375269</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-04-01T14:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why use the put function if the variables are Character with no conversion?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963207#M375294</link>
      <description>Thank you for your answer.&lt;BR /&gt;I had previously used Put to convert numeric to character values.  Input for character to numeric.  When I came across this use of Put I see this is a different use of it....since this is for all character values.  That was my question.</description>
      <pubDate>Wed, 02 Apr 2025 14:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963207#M375294</guid>
      <dc:creator>hmlong25</dc:creator>
      <dc:date>2025-04-02T14:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why use the put function if the variables are Character with no conversion?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963208#M375295</link>
      <description>&lt;P&gt;Formats convert values into text.&amp;nbsp; Numeric formats convert numbers into character string.&amp;nbsp; Character formats convert character strings into (possibly different) character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Informats convert text into values.&amp;nbsp; Numeric informats convert character strings into numbers.&amp;nbsp; Character informats convert character strings into (possibly different) character strings.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 15:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-use-the-put-function-if-the-variables-are-Character-with-no/m-p/963208#M375295</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-04-02T15:36:23Z</dc:date>
    </item>
  </channel>
</rss>

