<?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: Converting  char column to numeric format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778730#M247917</link>
    <description>Yes, you're right</description>
    <pubDate>Fri, 05 Nov 2021 12:41:41 GMT</pubDate>
    <dc:creator>Pandu2</dc:creator>
    <dc:date>2021-11-05T12:41:41Z</dc:date>
    <item>
      <title>Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778725#M247912</link>
      <description>Hi,&lt;BR /&gt;I've a temp dataset named "vipl" which has 5 columns named pr,qt,des,cod,addr in a library which is of type char but needs to convert it to numeric. I tried using input func. Below is the code.&lt;BR /&gt;&lt;BR /&gt;Data service.ipl;&lt;BR /&gt;Set service.vipl;(rename(pr=old qt=older));&lt;BR /&gt;pr=input(old,10.);&lt;BR /&gt;qt=input(older,10.);&lt;BR /&gt;drop old older;&lt;BR /&gt;run;&lt;BR /&gt;The above code gives a dataset by removing the existing columns i.e des,cod,addr and just giving pr,qt . So, can anyone help me in solving the issue. Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Nov 2021 12:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778725#M247912</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T12:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778728#M247915</link>
      <description>&lt;P&gt;You want the names to be the same, but the type to change from character to numeric, correct?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 12:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778728#M247915</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-05T12:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778730#M247917</link>
      <description>Yes, you're right</description>
      <pubDate>Fri, 05 Nov 2021 12:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778730#M247917</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T12:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778737#M247920</link>
      <description>&lt;P&gt;See if you can use this as a template&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   pr   = "1";
   qt   = "2";
   des  = "3";
   cod  = "4";
   addr = "5";
run;

data want;
   set have(rename = (pr = _pr qt = _qt des = _des cod = _cod addr = _addr));
   pr   = input(_pr, 8.);
   qt   = input(_qt, 8.);
   des  = input(_des, 8.);
   cod  = input(_cod, 8.);
   addr = input(_addr, 8.);
   drop _:;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 12:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778737#M247920</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-05T12:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778739#M247921</link>
      <description>Thanks for the help but, my issue is I just wanted to change the format for 2 columns pr,qt from char to numeric and the rest should be same which is char. And I did that but output dataset has only pr,qt didn't have the rest. Please refer my code.&lt;BR /&gt;Thanks.</description>
      <pubDate>Fri, 05 Nov 2021 13:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778739#M247921</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T13:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778742#M247922</link>
      <description>FYI,&lt;BR /&gt;The columns has char data which are numeric but the type of the column variable is char.</description>
      <pubDate>Fri, 05 Nov 2021 13:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778742#M247922</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T13:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778744#M247923</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   pr   = "1";
   qt   = "2";
   des  = "3";
   cod  = "4";
   addr = "5";
run;

data want;
   set have(rename = (pr = _pr qt = _qt));
   pr   = input(_pr, 8.);
   qt   = input(_qt, 8.);
   drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Nov 2021 13:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778744#M247923</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-05T13:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778747#M247925</link>
      <description>Yes, but that want output dataset hasn't had the rest of the columns.</description>
      <pubDate>Fri, 05 Nov 2021 13:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778747#M247925</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T13:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778750#M247928</link>
      <description>&lt;P&gt;Yes it does?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 13:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778750#M247928</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-05T13:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778754#M247929</link>
      <description>What I exactly need is among the 5 columns which has huge records. Two of them must be converted char to numeric and the resultant dataset should have format changed columns as well as rest of the columns(un formatted columns).</description>
      <pubDate>Fri, 05 Nov 2021 13:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778754#M247929</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T13:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778816#M247957</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405593"&gt;@Pandu2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;I've a temp dataset named "vipl" which has 5 columns named pr,qt,des,cod,addr in a library which is of type char but needs to convert it to numeric. I tried using input func. Below is the code.&lt;BR /&gt;&lt;BR /&gt;Data service.ipl;&lt;BR /&gt;Set service.vipl;(rename(pr=old qt=older));&lt;BR /&gt;pr=input(old,10.);&lt;BR /&gt;qt=input(older,10.);&lt;BR /&gt;drop old older;&lt;BR /&gt;run;&lt;BR /&gt;The above code gives a dataset by removing the existing columns i.e des,cod,addr and just giving pr,qt . So, can anyone help me in solving the issue. Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually no it doesn't. The semicolon after service.vipl will make the subsequent (rename ) invalid syntax.&lt;/P&gt;
&lt;P&gt;Show the code from your LOG with all the notes and messages. Copy the text from the log. On the forum open a text box using the &amp;lt;/&amp;gt; icon above the message window and paste the text.&lt;/P&gt;
&lt;P&gt;The text box is important because some diagnostics messages from SAS insert characters and the main message windows will reformat text making them less useful. The Log text is to see the actual code used and notes about the input and output data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also don't think you have completely described your problem. If you have random variables "disappear" that are not referenced in code shown then most likely a previous step corrupted data somewhere.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 15:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778816#M247957</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-05T15:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778819#M247960</link>
      <description>Thanks for letting me know it was my bad unfortunately I kept semicolon over there but there was no semicolon on my code. My issue is I have 5 columns in a dataset of those 2 needs to be converted to numeric. I used input func and also you can refer my code. Eventually the resultant dataset has only format changed columns rather having all the columns in the output dataset. I need some assistance in having include the rest of the columns as well.</description>
      <pubDate>Fri, 05 Nov 2021 16:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778819#M247960</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2021-11-05T16:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778857#M247980</link>
      <description>&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of your starting data set.&lt;/P&gt;
&lt;P&gt;Then we can write code that uses your actual data values.&lt;/P&gt;
&lt;P&gt;Note that the code will change the order of COLUMNS that variables appear in. If your data set has enough columns or use a small window to look at a data set you may just not be scrolling over to the right far enough to see the values you expect.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 17:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778857#M247980</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-05T17:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778888#M247996</link>
      <description>&lt;P&gt;Your code should work (assuming you fix the small typo and the names you used for the temporary names do not conflict with the names of other variables).&lt;/P&gt;
&lt;P&gt;You can make it a little more robust be making sure to remove any leading spaces that might be in the character variables.&amp;nbsp; Also the INPUT() function does not care if the informat width is longer than the character string be read so go ahead and just use the maximum 32 bytes that the numeric informat can handle.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data service.ipl;
  set service.vipl(rename(pr=old qt=older));
  pr=input(left(old),32.);
  qt=input(left(older),32.); 
  drop old older;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are seeing variables "disappear" then something else is happening.&lt;/P&gt;
&lt;P&gt;You ran different code than you posted.&lt;/P&gt;
&lt;P&gt;You looked at a different dataset than your code created.&lt;/P&gt;
&lt;P&gt;The code did not run and you are looking an existing dataset that was not replaced because of whatever issue caused the code to not run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS log will have the information that will let you figure out what happened.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 22:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778888#M247996</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-05T22:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Converting  char column to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778889#M247997</link>
      <description>&lt;P&gt;You were asked to post your log.&amp;nbsp;&lt;STRONG&gt;DO IT.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;See Maxim 2, the log is the most important start point for diagnostics.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 22:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-column-to-numeric-format/m-p/778889#M247997</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-05T22:28:38Z</dc:date>
    </item>
  </channel>
</rss>

