<?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 Changing values of SAS column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706651#M216892</link>
    <description>&lt;P&gt;I have a dataset with a column called "Type" which mainly consists of 2 values - "Ind" and "Fran". I would like to make that column numeric such that the value "Ind" is replaced with 1 and the value "Fran" is replaced with 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be more feasible to use a proc format or to use if-then statements in a data step? Could you give me an example of what the data step would look like considering that the datatype of the column will also have to be changed?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2020 15:14:04 GMT</pubDate>
    <dc:creator>aalluru</dc:creator>
    <dc:date>2020-12-17T15:14:04Z</dc:date>
    <item>
      <title>Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706651#M216892</link>
      <description>&lt;P&gt;I have a dataset with a column called "Type" which mainly consists of 2 values - "Ind" and "Fran". I would like to make that column numeric such that the value "Ind" is replaced with 1 and the value "Fran" is replaced with 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be more feasible to use a proc format or to use if-then statements in a data step? Could you give me an example of what the data step would look like considering that the datatype of the column will also have to be changed?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706651#M216892</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2020-12-17T15:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706654#M216893</link>
      <description>&lt;P&gt;You can use either PROC FORMAT or a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FORMAT does not make the variable numeric, the variable remains character, although it appears to us humans as 1 or 0. A data step would require you to create a new numeric variable that contains the numeric 0 and 1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if type='Ind' then type1=1;
    else if type='Fran' then type1=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706654#M216893</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-17T15:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706659#M216896</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue Ind_Fran
'Ind' = 1
'Fran' = 0
other = .;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So you're saying that this code would not change the datatype?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706659#M216896</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2020-12-17T15:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706660#M216897</link>
      <description>&lt;P&gt;Actually, I was thinking of using VALUE and not INVALUE. VALUE does not change the variable type. I haven't tried it with INVALUE, but I think it leaves the variable type unchanged. Formats and informats just change the appearance of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So you're saying that this code would not change the datatype?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The quickest answer is to try it yourself.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706660#M216897</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-17T15:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706662#M216898</link>
      <description>&lt;P&gt;Value is giving me an error&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706662#M216898</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2020-12-17T15:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706664#M216899</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Value is giving me an error&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For your future benefit, please understand that saying something gives an error, and not providing details, never helps. This provides no useful information to diagnose the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to see the LOG for these steps — the entire log for these steps, with nothing chopped out. We need to see the log in a format that preserves the formatting and readability of the log. Copy the log as text, and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon. I have stopped trying to read logs where these instructions are not followed.&amp;nbsp;&lt;STRONG&gt;DO NOT SKIP THIS STEP&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706664#M216899</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-17T15:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706665#M216900</link>
      <description>&lt;P&gt;Would it be possible then for me to drop type and rename type1 to type?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706665#M216900</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2020-12-17T15:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706668#M216902</link>
      <description>&lt;P&gt;oh alright. I am not planning on using format for what I need right now but I will keep that in mind in the future.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706668#M216902</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2020-12-17T15:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706677#M216906</link>
      <description>&lt;P&gt;No, this creates an informat that can then be applied to a data set or column but changes nothing by itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue Ind_Fran
'Ind' = 1
'Fran' = 0
other = .;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you're saying that this code would not change the datatype?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You would need to add an INPUT() statement to get the conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newVar = input(oldVar, ind_fran.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 16:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706677#M216906</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-17T16:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706681#M216910</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Value is giving me an error&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Once a SAS variable type is set you cannot change it.&lt;/P&gt;
&lt;P&gt;The informat would have to be used when either 1) initially reading the data into SAS or 2) create a NEW variable.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706681#M216910</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-17T15:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706683#M216911</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;oh alright. I am not planning on using format for what I need right now but I will keep that in mind in the future.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This isn't because someone doesn't want to help you, it's because it could be as simple as a missing semicolon or comma which is super easy to tell when you have the log but almost impossible without it. It helps you get answers faster.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706683#M216911</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-17T15:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Changing values of SAS column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706699#M216919</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Would it be possible then for me to drop type and rename type1 to type?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have (rename=(var = oldvar));
   var = input(oldvar, informat.);
   drop oldvar;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2020 16:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-values-of-SAS-column/m-p/706699#M216919</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-17T16:40:38Z</dc:date>
    </item>
  </channel>
</rss>

