<?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: Video: How to convert character to numeric in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585530#M166988</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;;&lt;/P&gt;
&lt;P&gt;To the best of my knowledge, the origin is Russian: "И волки сыты, и овцы целы" (lit: Both the wolves are sated and the sheep are intact).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yup, "have the cake and eat it, too" is the closest I can think of.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Sep 2019 01:25:52 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-09-02T01:25:52Z</dc:date>
    <item>
      <title>Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/568818#M160207</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So often this question comes up on the communities...and here's a tutorial video about how to convert character to numeric, and vice versa, in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKXCygvFrJqY%3Flist%3DPLVV6eZFA22QwrXd6nSDU18E6XgXSMOs87&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKXCygvFrJqY&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKXCygvFrJqY%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="600" height="337" scrolling="no" title="SAS Tutorial | How to convert character to numeric in SAS" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 17:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/568818#M160207</guid>
      <dc:creator>AnnaBrown</dc:creator>
      <dc:date>2019-06-25T17:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585447#M166958</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33307"&gt;@AnnaBrown&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;A very nice little lecture! Just a few (well-intended) notes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You mentioned that instead of creating a new data set with the new type-converted column, you can add this column to the original data set. That would be nice. Problem is, you can only add rows to an existing data set (via APPEND) but not columns; to achieve this effect, you have to completely &lt;EM&gt;rewrite&lt;/EM&gt; the whole file with the new variable added, which for large files can be quite taxing. However, the effect of adding a column can be emulated by creating a view (with the same conversion code you're showing) and referencing it down the line instead of the existing data set. This way, the wolves are no longer hungry (you got a new column), and the sheep are still alive (the original data set is not rewritten, and no disk space is wasted).&amp;nbsp; &amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;The way you code CATX, it creates the concatenated column with the default length of 200, which is rather unwieldy for this kind of result and just gobbles up disk space. This goes unnoticed for the audience because you don't show the SAS log; otherwise, it would see the corresponding log note.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;IMO, in teaching SAS showing the log is critical. The very first thing one routinely does after running a SAS program is examining the log for errors, warnings, notes, the number of records read and written, etc.; and only if everything is hunky-dory in the log department, going on to eyeball the output.&amp;nbsp; &amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Sep 2019 03:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585447#M166958</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-01T03:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585518#M166981</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;I like the wolf and sheep idiom! Where does it originate?&lt;/P&gt;
&lt;P&gt;Maybe the English version would be have your cake and eat it too? Or maybe this alteration of the famous adage: "no pain still gain"&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 00:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585518#M166981</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-02T00:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585530#M166988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;;&lt;/P&gt;
&lt;P&gt;To the best of my knowledge, the origin is Russian: "И волки сыты, и овцы целы" (lit: Both the wolves are sated and the sheep are intact).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yup, "have the cake and eat it, too" is the closest I can think of.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 01:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585530#M166988</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-02T01:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585942#M167200</link>
      <description>&lt;P&gt;You all make me laugh,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;! I'm adding&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/217204"&gt;@Anna_Yarbrough&lt;/a&gt;&amp;nbsp;(so many "Annas") to this discussion as she can speak to the areas you pointed out,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;. Thanks for viewing and sharing your input!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anna&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 20:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/585942#M167200</guid>
      <dc:creator>AnnaBrown</dc:creator>
      <dc:date>2019-09-03T20:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/586155#M167298</link>
      <description>&lt;P&gt;Hi Paul D.,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks for taking the time to watch and comment on this video! A few comments in response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Creating a View instead of Rewriting our Data:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Great point about creating a view! You can do this with PROC SQL or the DATA step. To do it with the DATA step just specify the VIEW option on the DATA statement. Here is an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data race_new / view=race_new;
	set race(rename=(race_date=race_date_old));
	race_date=input(race_date_old, date9.);
	format race_date mmddyy10.;
	drop race_date_old;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To look at the stored code in your view later, you can run a describe on the view:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data view=race_new;
describe;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;CATX and the length of NC_ID:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As you mentioned, the use of CATX here does create a column with a default length of 200 characters. If you run the code, there are actually no notes in the SAS log about this; however, doing a PROC CONTENTS on the newly created data set it is apparent, so let’s talk about how we can fix it. One easy fix is to use the length statement in the DATA step before the creation of the column. I can put this right after the SET statement, or if I want to maintain the order of my columns in my data set, I can put it right before I define the NC_ID column. Here is what that would look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length NC_ID $10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Showing the Log:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I agree, it is important to check out the log. I’ll be sure to highlight this more in future tutorials!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, thanks for taking the time to check out this tutorial. I hope you spend some more time exploring the other tutorials on the SAS Users YouTube channel!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 15:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/586155#M167298</guid>
      <dc:creator>Anna_Yarbrough</dc:creator>
      <dc:date>2019-09-04T15:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/586260#M167344</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/217204"&gt;@Anna_Yarbrough&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Thanks for your reply. I'd add a couple of things:&lt;/P&gt;
&lt;P&gt;1. Declaring NC_ID in the LENGTH statement beforehand is one way. A FORMAT statement with $&lt;EM&gt;w&lt;/EM&gt;. and appropriately selected &lt;EM&gt;W&lt;/EM&gt; work, too. The latter has the advantage in that it can be applied directly to the result of a CAT* function without a separate line of code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NC_ID = put (CATX (&amp;lt;arguments&amp;gt;), $10.) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The same trick can be used with any other character function returning $200 by default, such as REPEAT, IFC, etc. However, if the result is expected to be &lt;EM&gt;longer&lt;/EM&gt; than 200, sizing the receiving variable beforehand is imperative since otherwise the function's buffer will be limited to 200, while if the variable is already sized, the function uses its length as its buffer length up to 32767.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. "&lt;SPAN&gt;&lt;EM&gt;If you run the code, there are actually no notes in the SAS log about this&lt;/EM&gt;".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If &lt;EM&gt;I&lt;/EM&gt; run the code, I do get the note because I &lt;EM&gt;always&lt;/EM&gt; have the system option:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option msglevel=i ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;turned on. If you include it, you'll also get a log message like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;INFO: Character variables have defaulted to a length of 200 at the places given by:
      (Line):(Column). Truncation can result.
      4:3   NC_ID
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;In the real world, one shouldn't miss messages of this nature and correct one's code correspondingly if any are seen in the log. This is why I never run SAS without the option MSGLEVEL=I turned on and hence simply include it at the invocation or the config or autoexec file. Having it on also tells many other useful things, such as whether an index is defined; which access methods and execution plan SQL uses when you code the _METHOD and _TREE option with the SQL statement, and many other useful things.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Paul D.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 20:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/586260#M167344</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-04T20:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/589873#M168771</link>
      <description>&lt;P&gt;Full disclosure:&amp;nbsp; I haven't watched the video.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this subject matter really confused me when I first started SAS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Source Variable:&amp;nbsp; either numeric or character&lt;/LI&gt;
&lt;LI&gt;Target Variable:&amp;nbsp; either numeric or character&lt;/LI&gt;
&lt;LI&gt;Choice of Function:&amp;nbsp; either PUT() or INPUT()&lt;/LI&gt;
&lt;LI&gt;Choice of Format:&amp;nbsp;&amp;nbsp;either numeric or character format/informat&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's 2**4 possible combinations.&amp;nbsp;&amp;nbsp;Sheesh, no wonder I was confused &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, these rules below clarified it for me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PUT function:&amp;nbsp; ALWAYS returns character &lt;STRONG&gt;output&lt;/STRONG&gt;, accepts either character or numeric input.&lt;/LI&gt;
&lt;LI&gt;INPUT function:&amp;nbsp; ALWAYS expects character &lt;STRONG&gt;input&lt;/STRONG&gt;, returns either character or numeric output.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once I learned these rules, then it's just a matter of matching the format/informat type to the input/output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PUT function, character input, (always character output):&amp;nbsp; Use a character format.&lt;/LI&gt;
&lt;LI&gt;PUT function, numeric input, (always character output):&amp;nbsp; Use a numeric format.&lt;/LI&gt;
&lt;LI&gt;INPUT function, (always character input), character output:&amp;nbsp; Use a character informat.&lt;/LI&gt;
&lt;LI&gt;INPUT function, (always character input), numeric output:&amp;nbsp; Use a numeric informat.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, I always remember that, if I want a number as a returned value, use INPUT.&amp;nbsp; That also means if I'm using a user defined format (i.e. PROC FORMAT) I need to create a numeric &lt;STRONG&gt;INFORMAT&lt;/STRONG&gt;.&amp;nbsp; I've seen many a code sample where the end user created a numeric FORMAT, then used nested INPUT(PUT(...),...) to get the desired result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 01:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/589873#M168771</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-09-19T01:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/589884#M168776</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Thanks, Scott. A fantastic recap on one of the SAS topics that confuse tyros (and not only tyros) the most.&lt;/P&gt;
&lt;P&gt;Your list of the possible combinations also explains why there's no in/format that would have both numeric argument and numeric response - there's no combination of numeric input and numeric output for that.&lt;/P&gt;
&lt;P&gt;Speculating on the topic still further, I'd say that no piece of data enters the SAS System without an informat and leaves it without a format, respectively, no matter whether the in/format is used implicitly or explicitly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 01:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/589884#M168776</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-19T01:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/590595#M169054</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there is one more "funny" question, that was always bugging me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Character format and character informat - why two of them, is there any difference I'm missing that we need them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the bets&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $ abc
  "A"="a"
  "B"='b'
   C = c
  other = "_"
  ;

    value $ abc
  "A"="a"
  "B"='b'
   C = c
  other = "_"
  ;
run;


data Test;
  do letter = "A","B","C","D";
    f=  put(letter,$abc.);
    i=input(letter,$abc.);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Sep 2019 12:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/590595#M169054</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-09-21T12:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/590596#M169055</link>
      <description>&lt;P&gt;We have the same one in Polish: "Wilk syty i owca cała", but I'm not sure whether it is "native" or "imported" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In practice:&amp;nbsp;&lt;A href="https://desa.pl/media/img/cms/auction_objects/39623/582d1e9e618bc22267e685a346b2d0a8.jpg" target="_blank"&gt;https://desa.pl/media/img/cms/auction_objects/39623/582d1e9e618bc22267e685a346b2d0a8.jpg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B-)&lt;/P&gt;</description>
      <pubDate>Sat, 21 Sep 2019 12:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/590596#M169055</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-09-21T12:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/592563#M169918</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there is one more "funny" question, that was always bugging me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Character format and character informat - why two of them, is there any difference I'm missing that we need them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the bets&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $ abc
  "A"="a"
  "B"='b'
   C = c
  other = "_"
  ;

    value $ abc
  "A"="a"
  "B"='b'
   C = c
  other = "_"
  ;
run;


data Test;
  do letter = "A","B","C","D";
    f=  put(letter,$abc.);
    i=input(letter,$abc.);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Character format:&amp;nbsp; expects character input, always returns character output&lt;/LI&gt;
&lt;LI&gt;Character informat:&amp;nbsp; always expects character input, returns character output&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So sure, if you have character input and are desiring character output, then either a character format or informat will work (i.e. give you the desired results).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might get different results between the two if you munged the input/output data types, i.e. character format assigning to a numeric variable, or character informat with numeric input.&amp;nbsp; Sometimes SAS will do the implicit type conversion, and sometimes it generates an error, depending on the combination of function, in/format, input and output variable type.&amp;nbsp; I myself never like implicit type conversion, and I HATE errors :).&amp;nbsp; So, I always try to explicitly convert the type myself via INPUT/PUT.&amp;nbsp; Note that unnecessary type conversions (i.e. using a format when you should use an informat to return a numeric value) will affect performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, character informats (INVALUE statement) have additional options, such as JUST and UPCASE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* character format:   expects character input, always returns character output ;
* character informat: always expects character input, returns character output ;

proc format;
   * character informat, expects character input, always returns character output ;
   invalue $ abc
   "A"="a"
   "B"='b'
   C = c
   other = "_"
   ;

   * character format, always expects character input, returns character output ;
   value $ abc
   "A"="a"
   "B"='b'
   C = c
   other = "_"
   ;

   * testing: do quotes even matter? (nope, and is documented);
   invalue $ noq
   A=a
   B=b
   C=c
   other=_
   ;

   value $ noq
   A=a
   B=b
   C=c
   other=_
   ;

   * informats also have the upcase and just option ;
   invalue $just (just)
   A=X
   B=Y
   C=Z
   other=_
   ;

   invalue $upc (upcase)
   A=X
   B=Y
   C=Z
   other=_
   ;

   invalue $justupc (just upcase)
   A=X
   B=Y
   C=Z
   other=_
   ;

   %macro comment;
   value $upc (upcase)  /* but not formats, which makes sense */
   A=a
   B=b
   C=c
   other=_
   ;
   %mend comment;  * comment out using uncalled macro ;

   * a numeric informat ;
   invalue num 
   1=1
   2=2
   3=3
   other=.Z
   ;
run;


data Test1;
   do letter = "A","B","C","D";
      f=  put(letter,$abc.);
      i=input(letter,$abc.);
      output;
   end;
run;

data Test2;
   do letter = "A","B","C","D";
      f=  put(letter,$noq.);
      i=input(letter,$noq.);
      output;
   end;
run;

data Test3A;  * justify ;
   length letter $5;
   do letter = "A"," B","  C","   D";
      i=input(letter,$just5.);
      output;
   end;
run;

data Test3B;  * upcase ;
   length letter $5;
   do letter = "a","b","c","d";
      i=input(letter,$upc5.);
      output;
   end;
run;

data Test3C;  * justify+upcase ;
   length letter $5;
   do letter = "a"," b","  c","   d";
      i=input(letter,$justupc5.);
      output;
   end;
run;

data Test4;
   do num=1 to 4;  
      i=input(num,num.);  * implicit type conversion for the input function ;
      i2=input(put(num,best.),num.);  * explicit type conversion for the input function ;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getting the Test3's to give the correct results was tricky; I finally remembered to add a length suffix to the informats, since the default length is based on the input values (with a little help from Google and&amp;nbsp;&lt;A href="http://support.sas.com/resources/papers/proceedings10/022-2010.pdf" target="_blank" rel="noopener"&gt;http://support.sas.com/resources/papers/proceedings10/022-2010.pdf&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you noted in your code, the quotes are optional.&amp;nbsp; From the doc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1pmw90bl3jzgdn1w4202kclxtho.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1pmw90bl3jzgdn1w4202kclxtho.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If you omit the single or double quotation marks around&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;character-string&lt;/SPAN&gt;&lt;SPAN&gt;, then the INVALUE statement assumes that the quotation marks are there.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The VALUE statement says:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;You must enclose a formatted value in single or double quotation marks. The following example shows a formatted value that is enclosed in double quotation marks&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the above shows that is not always the case.&amp;nbsp; I thought they would be required if the label contains spaces, but that does not appear to be the case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   * testing: do quotes even matter? ;
   invalue $ noq
   A=a a a
   B=b
   C=c
   other=_
   ;

   value $ noq
   A=a
   B=b b b 
   C=c
   other=_
   ;
run;

data Test2;
   do letter = "A","B","C","D";
      f=  put(letter,$noq.);
      i=input(letter,$noq.);
      output;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above appears to work, but doesn't give the correct results if you do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $ noq
   A=a
   B=b b b 
   C C C=c
   other=_
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best practice is to follow the SAS documentation regarding quotation marks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;HTH...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 05:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/592563#M169918</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-09-30T05:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/592579#M169925</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scott thanks for your response, it definitely helped! Thank you for reminding me that JUST and UPCASE are only available in informats, I should checked out the doc instead my memory... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Few thoughts:&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) You wrote:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I myself never like implicit type conversion, and I HATE errors&lt;/SPAN&gt;&lt;SPAN&gt;.&amp;nbsp; So, I always try to explicitly convert the type myself via INPUT/PUT.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I couldn't agree more. Doing implicit&amp;nbsp;&lt;/SPAN&gt;conversion is very hmmm....&amp;nbsp; "un-elegant". I have my small "metaphor" about such programming practice but it is not suitable for "public debate" &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; maybe if we'll have chance to talk face to face I share &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b) Thanks for Ron Cody's article, I'll read it for sure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;c) I also agree about quotes, true I used one without quotes in my example, but in practice I think quoting is the best practice. The last example you shared:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $ noq
   A=a
   B=b b b 
   C C C=c
   other=_
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;that behaviour looks like the Title's behaviour, you could do it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title "A b c d" C=red " e f g";
proc print data = sashelp.class(obs=1);
run;

title A b c d C=red e f g ;
proc print data = sashelp.class(obs=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Both "works" but the first one is 1) clearer 2) "warningless".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 08:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/592579#M169925</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-09-30T08:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/635479#M188687</link>
      <description>&lt;P&gt;Hello there!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the video and the simple explanation for put and input. Well, "simple" ... As simple as it can get with SAS, let's say.&lt;/P&gt;&lt;P&gt;All those puts and inputs, date9s, z3.s are pretty much why starters are so unhappy with SAS. Any intutive way to understand that? Any experience with other programming languages which you could transfer and use? Tbh, I don't see it and I understand some people in my department, who are using SAS only to download data, put it (or input it, lol) in Excel or R and then go on from there. The learning curve in SAS is just very slow and often frustrating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 07:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/635479#M188687</guid>
      <dc:creator>AndreasF</dc:creator>
      <dc:date>2020-03-28T07:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/635486#M188693</link>
      <description>&lt;P&gt;R easier to learn than SAS? You had a hell of a good teacher!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The numeric formats date9. and z4. are way to format numbers into strings.&lt;/P&gt;
&lt;P&gt;Is that number to be displayed as a hex string? a date? a time? how many decimals do you want? or leading zeros? or percent or dollar sign? &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The numeric informats date9. etc allow the reverse: read a string as a (into a) number.&lt;/P&gt;
&lt;P&gt;If that string a date? a time? in what format? and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 09:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/635486#M188693</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-28T09:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/655577#M196684</link>
      <description>First to convert a character variable into number, user needs to store that numeric variable into a new variable. It can be done by two methods:&lt;BR /&gt;-- multiply by 1 ( Character var * 1) --&amp;gt; convert the char var into a numeric variable&lt;BR /&gt;Eg - new_var = char var * 1&lt;BR /&gt;-- use Sas inbuilt method INPUT.&lt;BR /&gt;Syntax - INPUT ( Var name, w.d);</description>
      <pubDate>Tue, 09 Jun 2020 16:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/655577#M196684</guid>
      <dc:creator>sagarwal1</dc:creator>
      <dc:date>2020-06-09T16:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/655606#M196693</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316144"&gt;@sagarwal1&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Methinks using the "multiplication method" is a poor practice: It results in an implicit character-to-numeric type conversion and pollutes the log with a corresponding note "Character values have been converted to numeric values...". Besides, if the input is not a valid number, it will pollute the log even more with two more notes: "Invalid numeric data..." and "Missing values were generated...".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's always much cleaner to use the INPUT function with a corresponding informat preceded by the ?? modifier. This way, you get a clean log without any vagaries and can test the result for a missing value if need be to find out if the informat has failed to interpret the input as a number or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 17:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/655606#M196693</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2020-06-09T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/658220#M197268</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&lt;BR /&gt;I appreciate for guiding in what will be the consequences of using multiplication method to convert character variable to numerical variable. I tried using this method to convert into number and it worked. So I suggested others to use it but I personally use INPUT method to get rid of unexpected problems. Once again, thanks for your clarification.</description>
      <pubDate>Fri, 12 Jun 2020 22:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/658220#M197268</guid>
      <dc:creator>sagarwal1</dc:creator>
      <dc:date>2020-06-12T22:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/665443#M198985</link>
      <description>Nice</description>
      <pubDate>Fri, 26 Jun 2020 19:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/665443#M198985</guid>
      <dc:creator>angelojun2k</dc:creator>
      <dc:date>2020-06-26T19:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Video: How to convert character to numeric in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/697469#M213145</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I tried using this method to convert into number and it worked.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;You can only say "it worked" if you disregard message in the log. And you should &lt;EM&gt;never&lt;/EM&gt; ignore log messages.&lt;/P&gt;
&lt;P&gt;A good program generates a clean log. A bad program doesn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 22:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Video-How-to-convert-character-to-numeric-in-SAS/m-p/697469#M213145</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-11-08T22:19:33Z</dc:date>
    </item>
  </channel>
</rss>

