<?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 data type to character--even if it's already character in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125451#M34487</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the field is in a text file you can simply import it into a character variable :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myData;&lt;/P&gt;&lt;P&gt;infile "myPath\myFile.txt";&lt;/P&gt;&lt;P&gt;length myField $12;&lt;/P&gt;&lt;P&gt;input x myField y;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the field is an Excel worksheet column then you must include the mixed=yes option in the libname statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname xl Excel "myPath\myFile.xls" mixed=yes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myData;&lt;/P&gt;&lt;P&gt;set xl.'Sheet1$'n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 02 Mar 2013 02:05:20 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-03-02T02:05:20Z</dc:date>
    <item>
      <title>Convert data type to character--even if it's already character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125450#M34486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When importing data into SAS, there is a field that is sometimes numeric, and sometimes character.&amp;nbsp; How can I always convert it to character?&amp;nbsp; It seems like there is not a way to convert a character to a character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this on the import, such as declaring the field a character datatype when I import the file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 00:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125450#M34486</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-02T00:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert data type to character--even if it's already character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125451#M34487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the field is in a text file you can simply import it into a character variable :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myData;&lt;/P&gt;&lt;P&gt;infile "myPath\myFile.txt";&lt;/P&gt;&lt;P&gt;length myField $12;&lt;/P&gt;&lt;P&gt;input x myField y;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the field is an Excel worksheet column then you must include the mixed=yes option in the libname statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname xl Excel "myPath\myFile.xls" mixed=yes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myData;&lt;/P&gt;&lt;P&gt;set xl.'Sheet1$'n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 02:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125451#M34487</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-03-02T02:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert data type to character--even if it's already character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125452#M34488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Best way is to not use IMPORT.&amp;nbsp; Instead have the files supplied to you in a known format and read them using a program.&amp;nbsp; Then you have control over how the variables are named and the type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 04:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125452#M34488</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-02T04:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Convert data type to character--even if it's already character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125453#M34489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up using CATS() in the proc sql to convert the field to a character.&amp;nbsp; This works even if it was already a character to begin with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 20:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-data-type-to-character-even-if-it-s-already-character/m-p/125453#M34489</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-04T20:01:44Z</dc:date>
    </item>
  </channel>
</rss>

