<?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: Change a numeric variable to input a character variable. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/351021#M63885</link>
    <description>&lt;P&gt;General hint: SAS data sets have exactly two data types: numeric and character. The type, once set, cannot change. Attempting to assign a character value to numeric will generally fail unless your character value happens to look numeric: '123.45' for instance. At which point SAS will attempt to do what you want but will generate a note in the log about conversion of character to numeric (or vice versa). But if the value cannot by any stretch of the imagination be numeric such as "In-store" then it fails and you get the result you encountered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One nice thing about SAS though is that you can use a custom format to display desired text based on a numeric value or range of values.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2017 19:57:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-18T19:57:08Z</dc:date>
    <item>
      <title>Change a numeric variable to input a character variable.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/350981#M63880</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with the variable Order_Type and it has numeric values of 1 2 and 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to take those numeric values and have them changed into different words.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So&amp;nbsp;Order_Type 1 should be labeled as ‘In-Store’&amp;nbsp;&lt;/P&gt;&lt;P&gt;Order_Type 2 should be labeled as ‘Catalogue’&lt;/P&gt;&lt;P&gt;Order_Type 3 should be labeled as ‘Web’&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting errors when trying this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data orders;&lt;/P&gt;&lt;P&gt;set BUS_4024.dly_orders;&lt;/P&gt;&lt;P&gt;if Order_Type = 1 then Order_Type = "In-store";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warnings&amp;nbsp;say "Invalid numeric data, 'In-store'" for every line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im not that great with SAS but have been trying my best. Really appreciate any help, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 18:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/350981#M63880</guid>
      <dc:creator>sammydouglas</dc:creator>
      <dc:date>2017-04-18T18:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Change a numeric variable to input a character variable.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/350984#M63881</link>
      <description>nevermind, i read the question wrong! Apparently I need to create a new variable Order_Type_Labels and have that variable list the words according to the number.</description>
      <pubDate>Tue, 18 Apr 2017 19:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/350984#M63881</guid>
      <dc:creator>sammydouglas</dc:creator>
      <dc:date>2017-04-18T19:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Change a numeric variable to input a character variable.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/351020#M63884</link>
      <description>&lt;P&gt;Look into how to use formats.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  value Order_Type 1=‘In-Store’  2=‘Catalogue’ 3=‘Web’;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can have it display the descriptive text without changing the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have ;
  tables order_type;
  format order_type order_type.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 19:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/351020#M63884</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T19:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Change a numeric variable to input a character variable.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/351021#M63885</link>
      <description>&lt;P&gt;General hint: SAS data sets have exactly two data types: numeric and character. The type, once set, cannot change. Attempting to assign a character value to numeric will generally fail unless your character value happens to look numeric: '123.45' for instance. At which point SAS will attempt to do what you want but will generate a note in the log about conversion of character to numeric (or vice versa). But if the value cannot by any stretch of the imagination be numeric such as "In-store" then it fails and you get the result you encountered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One nice thing about SAS though is that you can use a custom format to display desired text based on a numeric value or range of values.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 19:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-a-numeric-variable-to-input-a-character-variable/m-p/351021#M63885</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-18T19:57:08Z</dc:date>
    </item>
  </channel>
</rss>

