<?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: How to create a character and numeric value with provided code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519658#M140798</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input x 1-2 @4 state $upcase2.;
cards;
123nj76543
892NY10203
876pA83745
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Dec 2018 17:12:04 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-12-08T17:12:04Z</dc:date>
    <item>
      <title>How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519592#M140751</link>
      <description>&lt;P&gt;Code is:&lt;/P&gt;&lt;P&gt;****&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;string;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;inputstring $10.;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;123nj76543&lt;/P&gt;&lt;P&gt;892NY10203&lt;/P&gt;&lt;P&gt;876pA83745&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;****&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could I create a numeric variable called x that contains the first two digits of the string? How could I create a character variable called state that contains the fourth and fifth characters (uppercase)?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 22:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519592#M140751</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T22:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519595#M140752</link>
      <description>&lt;P&gt;Do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA string;
input string $10.;
DATALINES;
123nj76543
892NY10203
876pA83745
;
RUN;

data want;
   set string;
   var1=input(substr(string, 1, 2), best.);
   var2=upcase(substr(string, 4, 2));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 22:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519595#M140752</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-07T22:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519597#M140753</link>
      <description>&lt;P&gt;data DATAstring;&lt;BR /&gt;length x 8.;&lt;BR /&gt;input inputstring $10.;&lt;BR /&gt;x = substr(inputstring,1,2);&lt;BR /&gt;state = upcase(substr(inputstring,4,2));&lt;BR /&gt;DATALINES;&lt;BR /&gt;123nj76543&lt;BR /&gt;892NY10203&lt;BR /&gt;876pA83745&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 22:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519597#M140753</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-07T22:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519598#M140754</link>
      <description>&lt;P&gt;Thanks. How do you differentiate between it being a character versus a numeric variable?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519598#M140754</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T23:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519600#M140756</link>
      <description>&lt;P&gt;See my answer above. I use the input function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519600#M140756</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-07T23:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519601#M140757</link>
      <description>&lt;P&gt;the length x 8. makes x numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519601#M140757</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-07T23:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519602#M140758</link>
      <description>&lt;P&gt;Ohh ok, I understand now. Thanks guys!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519602#M140758</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T23:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519603#M140759</link>
      <description>&lt;P&gt;did you question and needs get resolved?&lt;/P&gt;
&lt;P&gt;Thanks is nice but the communities doesn't see that your needs have been fulfilled without you selecting a solution.&lt;/P&gt;
&lt;P&gt;Please help the community by selecting and approving one of the replies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519603#M140759</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-07T23:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519605#M140761</link>
      <description>&lt;P&gt;Good to know. I've accepted your solution VDD.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519605#M140761</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T23:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519608#M140762</link>
      <description>&lt;P&gt;Note that using the code provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;will cause a long entry like:&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
&lt;/PRE&gt;
&lt;P&gt;which is not an error but sometimes indicates something odd has happened to your data or the code could use some cleaning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is why &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;used an INPUT to do the explicit conversion from character to numeric.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519608#M140762</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-07T23:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519647#M140792</link>
      <description>&lt;P&gt;With perl regular expression you could also achieve the same as below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA string;
    input string $10.;
	x=prxchange('s/(^\d{1,2})(\d\w*)/$1/i',-1,strip(string));
	state=prxchange('s/(\d?)//i',-1,upcase(strip(string)));

DATALINES;
123nj76543
892NY10203
876pA83745
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Dec 2018 13:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519647#M140792</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-12-08T13:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519654#M140795</link>
      <description>&lt;P&gt;So bored today&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA string;
input string $10.;
DATALINES;
123nj76543
892NY10203
876pA83745
;
RUN;

data want;
set string;
x=peekclong(addrlong(string),2);
state=upcase(compress(string,,'kai'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set string;
x=peekclong(addrlong(string),2);
state=upcase(compress(string,,'d'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Dec 2018 16:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519654#M140795</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-08T16:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a character and numeric value with provided code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519658#M140798</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input x 1-2 @4 state $upcase2.;
cards;
123nj76543
892NY10203
876pA83745
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Dec 2018 17:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-character-and-numeric-value-with-provided-code/m-p/519658#M140798</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-08T17:12:04Z</dc:date>
    </item>
  </channel>
</rss>

