<?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: Replacing entries in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343436#M78844</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

If A=1,B=2 -- Z=26 and you character code is ascii

data SAMPLEEDUCATION;
  input Education_Level $1.;
  if anyalpha(education_level) then num=rank(Education_Level) -64;
  else num=input(Education_Level,1.);
cards4;
1
2
3
4
1
2
3
4
1
4
A
B
C
D
;;;;
run;quit;


Up to 40 obs WORK.SAMPLEEDUCATION total obs=14

       EDUCATION_
Obs      LEVEL       NUM

  1        1          1
  2        2          2
  3        3          3
  4        4          4
  5        1          1
  6        2          2
  7        3          3
  8        4          4
  9        1          1
 10        4          4
 11        A          1
 12        B          2
 13        C          3
 14        D          4



&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Mar 2017 17:54:30 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-03-22T17:54:30Z</dc:date>
    <item>
      <title>Replacing entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343376#M78819</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with a variable that is suppose to only be numeric from 1 through 4, but has some extra variables like A B C and D. I am trying to change those alphabetical variables to the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A = 1; B = 2; C = 3; D = 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What exactly is the sas code for this? Here's a sample dataset Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CDC.SAMPLEEDUCATION;
  infile datalines dsd truncover;
  input Education_Level:$1.;
datalines4;
1
2
3
4
1
2
3
4
1
4
A
B
C
D
;;;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 16:23:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343376#M78819</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-03-22T16:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343382#M78822</link>
      <description>There are many ways. The translate function,  the case statement in SQL, to name a few.</description>
      <pubDate>Wed, 22 Mar 2017 16:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343382#M78822</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-03-22T16:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343386#M78824</link>
      <description>&lt;P&gt;A custom informat would do what you want directly in the data step:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    invalue fixMe
        'A' = 1
        'B' = 2
        'C' = 3
        'D' = 4
        OTHER = [best.];
run;
 

data  SAMPLEEDUCATION;
  infile datalines dsd truncover;
  input Education_Level :fixMe.;
datalines4;
1
2
3
4
1
2
3
4
1
4
A
B
C
D
;;;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 16:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343386#M78824</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-22T16:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343436#M78844</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

If A=1,B=2 -- Z=26 and you character code is ascii

data SAMPLEEDUCATION;
  input Education_Level $1.;
  if anyalpha(education_level) then num=rank(Education_Level) -64;
  else num=input(Education_Level,1.);
cards4;
1
2
3
4
1
2
3
4
1
4
A
B
C
D
;;;;
run;quit;


Up to 40 obs WORK.SAMPLEEDUCATION total obs=14

       EDUCATION_
Obs      LEVEL       NUM

  1        1          1
  2        2          2
  3        3          3
  4        4          4
  5        1          1
  6        2          2
  7        3          3
  8        4          4
  9        1          1
 10        4          4
 11        A          1
 12        B          2
 13        C          3
 14        D          4



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 17:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-entries/m-p/343436#M78844</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-22T17:54:30Z</dc:date>
    </item>
  </channel>
</rss>

