<?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: Changing numeric variable to character variable with different lengths in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696431#M25269</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344374"&gt;@mady3&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example of what I described in my initial response can be seen below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(rename = (c_height = height));
   set sashelp.class;

   length c_height $ 4;

   c_height = put(height,4.1);

   drop height;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2020 10:21:13 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2020-11-04T10:21:13Z</dc:date>
    <item>
      <title>Changing numeric variable to character variable with different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696411#M25267</link>
      <description>&lt;P&gt;My data has the following variables:&amp;nbsp;&lt;/P&gt;&lt;P&gt;SSN ($11)&lt;/P&gt;&lt;P&gt;Inits ($4)&lt;/P&gt;&lt;P&gt;City ($20)&lt;/P&gt;&lt;P&gt;ZipCd (8)&lt;/P&gt;&lt;P&gt;StateCd ($2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the code I have:&lt;/P&gt;&lt;P&gt;DATA WORK.XXX;&lt;BR /&gt;SET YYY;&lt;/P&gt;&lt;P&gt;IF State = 'IOWA' THEN StateCd = 'IA';&lt;BR /&gt;&lt;BR /&gt;KEEP SSN -- ZipCd;&lt;BR /&gt;KEEP StateCd;&lt;BR /&gt;DROP Sex -- BirthDt;&lt;BR /&gt;DROP State;&lt;BR /&gt;&lt;BR /&gt;Initials=CATS(Scan(Initials, -1, ','), SCAN(Initials, 1, ','));&lt;BR /&gt;&lt;BR /&gt;RENAME Initials = Inits;&lt;BR /&gt;City = PROPCASE(City);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to change the 'ZipCd' variable from numeric to character as well as change the length from 8 to 5. I have tried a PUT function but due to the other statements in my code I am unsure on the placement of the PUT function that will allow these changes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696411#M25267</guid>
      <dc:creator>mady3</dc:creator>
      <dc:date>2020-12-10T15:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Changing numeric variable to character variable with different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696414#M25268</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344374"&gt;@mady3&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once a variable's type has been set it cannot be changed, so you'll have to create another variable, e.g. c_&lt;SPAN&gt;ZipCd&lt;/SPAN&gt; as character, assign it the value held in&amp;nbsp;&lt;SPAN&gt;ZipCd, drop&amp;nbsp;ZipCd and then rename your c_ZipCd to&amp;nbsp;ZipCd.&lt;/SPAN&gt;&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;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Amir.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 07:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696414#M25268</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-11-04T07:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Changing numeric variable to character variable with different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696431#M25269</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344374"&gt;@mady3&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example of what I described in my initial response can be seen below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(rename = (c_height = height));
   set sashelp.class;

   length c_height $ 4;

   c_height = put(height,4.1);

   drop height;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 10:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696431#M25269</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-11-04T10:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Changing numeric variable to character variable with different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696778#M25301</link>
      <description>&lt;P&gt;Hi Amir,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 06:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696778#M25301</guid>
      <dc:creator>mady3</dc:creator>
      <dc:date>2020-11-05T06:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Changing numeric variable to character variable with different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696801#M25303</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344374"&gt;@mady3&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No problem, happy to help when I can. Does that mean your problem has been addressed or do you still have an issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is addressed then you can mark a response as the solution, otherwise post details of the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 08:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-numeric-variable-to-character-variable-with-different/m-p/696801#M25303</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-11-05T08:49:31Z</dc:date>
    </item>
  </channel>
</rss>

