<?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: proc format:why a numeric field change to char in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644499#M192504</link>
    <description>&lt;P&gt;Formats only change the appearance of the values in the field. Formats do not change the actual value, and formats do not change a variable from numeric to character.&lt;/P&gt;</description>
    <pubDate>Fri, 01 May 2020 11:44:43 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-05-01T11:44:43Z</dc:date>
    <item>
      <title>proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644493#M192503</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I apply&amp;nbsp; Format on numeric column.&lt;/P&gt;
&lt;P&gt;Why the field is changing to alphanumeric?&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data  tbl;
input ID score;
cards;
1 7
2 8
3 6
4 11
;
Run;

proc format;
value FFMT;
0='1'
1-7='2'
8-10='3'
11='4';
run;

data tbl2;
set tbl;
format  score FFMT.;
Run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What will be the difference If I define the format without quotes ''&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value Ffmt
0=1
2-7=2
8-10=3
11=4;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 11:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644493#M192503</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-05-01T11:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644499#M192504</link>
      <description>&lt;P&gt;Formats only change the appearance of the values in the field. Formats do not change the actual value, and formats do not change a variable from numeric to character.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 11:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644499#M192504</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-01T11:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644501#M192506</link>
      <description>&lt;P&gt;Run a proc contents and you will see that the variable is still numeric. Formats do not change the type of the variable to which they are attached, only the display.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 11:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644501#M192506</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-01T11:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644513#M192513</link>
      <description>&lt;P&gt;What is the expected variable type of x_new1 and x_new2?&lt;/P&gt;
&lt;P&gt;I expected that x_new2 will be char and x_new1 will be numeric.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data a;
input ID x;
cards;
1 7
2 11
3 8
4 4
5 10
;
run;

proc format;
value ffmt
0=1
2-10=2
11=3
;
run;

proc format;
value ff2mt;
0='1'
2-10='2'
11='3'
;
run;


data b;
set a;
x_new1=put(x,ffmt.);
x_new2=put(x,ff2mt.);
Run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 13:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644513#M192513</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-05-01T13:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644519#M192517</link>
      <description>&lt;P&gt;PUT() takes a numeric variable and creates a new character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT() cannot result in a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is clearly and explicitly stated in the documentation for PUT, which says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Use the PUT function to convert a numeric value to a character value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 01 May 2020 14:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644519#M192517</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-01T14:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644532#M192521</link>
      <description>&lt;P&gt;Whether you use quotes in the VALUE or INVALUE statement does not impact what type of FORMAT you are creating.&amp;nbsp; The quotes are optional only to maintain backwards compatibility with older versions of SAS.&amp;nbsp; But it is good coding style to use the quotes around the text strings and not use them around the numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To create a character format use the VALUE and a $ prefix on the format name.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value $FFMT ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To create a character informat use the INVALUE statement and a $ prefix on the informat name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;invalue $FFMT ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format converts values into text, so the label (right of the equal sign) should be in quotes for both numeric and character formats.&lt;/P&gt;
&lt;P&gt;An informat converts text into values, so the range specification (left of the equal sign) should be in quotes.&lt;/P&gt;
&lt;P&gt;A numeric format works on numbers, so the range specification (left of the equal sign) should NOT be in quotes.&lt;/P&gt;
&lt;P&gt;A numeric informat generates numbers, so the label (right of the equal sing) should NOT be in quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 14:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644532#M192521</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-01T14:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644535#M192523</link>
      <description>&lt;P&gt;Formats convert values to text. Informats convert text to values.&lt;/P&gt;
&lt;P&gt;Numeric formats convert numbers to text.&amp;nbsp; Character formats convert text to text.&lt;/P&gt;
&lt;P&gt;Numeric informats convert text to numbers. Character informats convert text to text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert numbers to numbers you need to use a format and then an informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x_new1=input(put(x,ffmt.),32.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 May 2020 14:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644535#M192523</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-01T14:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc format:why a numeric field change to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644997#M192738</link>
      <description>&lt;P&gt;So you did not use an existing variable wich somehow magically changed its type, you &lt;STRONG&gt;CREATED A NEW VARIABLE&lt;/STRONG&gt; by assigning the result of a PUT() function. That will always result in the new variable being of type character, because the PUT() function returns a character value.&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 13:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-why-a-numeric-field-change-to-char/m-p/644997#M192738</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-04T13:41:46Z</dc:date>
    </item>
  </channel>
</rss>

