<?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: Convert numeric to character in a query in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3252#M1696</link>
    <description>Thanks, Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
Still being so darn new to all that SAS has to offer, I wasn't sure if the PUT code could be used inside a query.  Your advice, as always, comes in handy!</description>
    <pubDate>Tue, 29 May 2007 17:16:34 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-05-29T17:16:34Z</dc:date>
    <item>
      <title>Convert numeric to character in a query</title>
      <link>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3250#M1694</link>
      <description>I've got a query that creates a new output table field by concatenating a variable to an input table field as follows:&lt;BR /&gt;
&lt;BR /&gt;
"&amp;amp;threespaces" || EMPLOYEE.PERSON_UID,9) as NEWKEY&lt;BR /&gt;
&lt;BR /&gt;
However, when I run my query, it complains because the EMPLOYEE_PERSON_UID is numeric.  How might I convert this field so the query doesn't complain?  I am aware that SAS usually ignores spaces or blanks at the beginning of a field, however, this field needs the "threespaces" at its beginning.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance!</description>
      <pubDate>Tue, 29 May 2007 13:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3250#M1694</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-29T13:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric to character in a query</title>
      <link>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3251#M1695</link>
      <description>Hi:&lt;BR /&gt;
  SAS is really picky about the difference between character and numeric variables -- and spaces are not valid in a number. I assume that you want the NEWKEY variable to be character. The key is doing your concatenate with a PUT function to turn the ID variable into a character value for the concatenate operation. Then the format=$char12. will tell SAS to respect the leading blanks in the new field--which will be a CHARACTER variable.&lt;BR /&gt;
  Good luck!&lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data employee;&lt;BR /&gt;
infile datalines;&lt;BR /&gt;
input name $ PERSON_UID;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
alma 123456789&lt;BR /&gt;
bob  234567890&lt;BR /&gt;
carl 345678901&lt;BR /&gt;
dave 456789012&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
   &lt;BR /&gt;
proc print data=employee;&lt;BR /&gt;
title 'person_uid is numeric';&lt;BR /&gt;
run;&lt;BR /&gt;
   &lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create table testit as&lt;BR /&gt;
    select name, employee.person_uid,&lt;BR /&gt;
	       '   '||left(put(employee.person_uid,9.)) as NEWKEY format=$char12.&lt;BR /&gt;
    from work.employee as employee;&lt;BR /&gt;
quit;&lt;BR /&gt;
   &lt;BR /&gt;
proc print data=testit;&lt;BR /&gt;
title 'NEWKEY is a character variable';&lt;BR /&gt;
title2 'So the PUT function was used to turn a numeric var into a character value for the concat.';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 29 May 2007 15:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3251#M1695</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-05-29T15:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric to character in a query</title>
      <link>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3252#M1696</link>
      <description>Thanks, Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
Still being so darn new to all that SAS has to offer, I wasn't sure if the PUT code could be used inside a query.  Your advice, as always, comes in handy!</description>
      <pubDate>Tue, 29 May 2007 17:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3252#M1696</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-29T17:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric to character in a query</title>
      <link>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3253#M1697</link>
      <description>Hi!&lt;BR /&gt;
  You have soooo much fun to look forward to. Between the SAS formats and the SAS functions you can do a lot of very cool stuff:&lt;BR /&gt;
Formats and Informats:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi25/25/aa/25p002.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi25/25/aa/25p002.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi26/p085-26.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi26/p085-26.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.kellogg.northwestern.edu/rc/workshops/papers/finley_sugi25.pdf" target="_blank"&gt;http://www.kellogg.northwestern.edu/rc/workshops/papers/finley_sugi25.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www8.sas.com/scholars/05/PREVIOUS/2001_200.4/2004_MOR/Proceed/_2004/IntroductionToSAS/IN06-Droogendyk.pdf" target="_blank"&gt;http://www8.sas.com/scholars/05/PREVIOUS/2001_200.4/2004_MOR/Proceed/_2004/IntroductionToSAS/IN06-Droogendyk.pdf&lt;/A&gt;&lt;BR /&gt;
     &lt;BR /&gt;
Functions:&lt;BR /&gt;
&lt;A href="http://www8.sas.com/scholars/05/SESUG_05/Proceedings/2005/Intro2SAS/IN08_05.PDF" target="_blank"&gt;http://www8.sas.com/scholars/05/SESUG_05/Proceedings/2005/Intro2SAS/IN08_05.PDF&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/255-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/255-29.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
&lt;A href="http://www.hasug.org/newsletters/hasug200511/Muir_Character_Function_Fun.pdf" target="_blank"&gt;http://www.hasug.org/newsletters/hasug200511/Muir_Character_Function_Fun.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
&lt;A href="http://www.uchsc.edu/coho/SAS_Uers/FavoriteFunctions.doc" target="_blank"&gt;http://www.uchsc.edu/coho/SAS_Uers/FavoriteFunctions.doc&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
The SAS documentation is quite good on the subject of functions and formats/informats. The SAS functions and odd behavior in PROC SQL are described here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/techsup/unotes/SN/014/014659.html" target="_blank"&gt;http://support.sas.com/techsup/unotes/SN/014/014659.html&lt;/A&gt;&lt;BR /&gt;
  &lt;BR /&gt;
and here's a note about functions and PROC SQL:&lt;BR /&gt;
&lt;A href="http://support.sas.com/ctx/samples/index.jsp?sid=819" target="_blank"&gt;http://support.sas.com/ctx/samples/index.jsp?sid=819&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Have fun!&lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 29 May 2007 18:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3253#M1697</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-05-29T18:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric to character in a query</title>
      <link>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3254#M1698</link>
      <description>Thanks for the information, Cynthia.  I truly appreciate it.</description>
      <pubDate>Fri, 01 Jun 2007 20:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-numeric-to-character-in-a-query/m-p/3254#M1698</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-06-01T20:40:23Z</dc:date>
    </item>
  </channel>
</rss>

