<?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 Converting character to numeric then ordering and sorting it SAS 9.4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634454#M188301</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable that reflect education level.&amp;nbsp; I would like to convert this variable to numeric and then tell SAS I want to highest level of education per person.&amp;nbsp; As of now, all levels of education are showing up per person and are character i.e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Education&lt;/P&gt;&lt;P&gt;0000 &amp;nbsp; &amp;nbsp;&amp;nbsp; High School&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Associates&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bachelors&lt;/P&gt;&lt;P&gt;0001 &amp;nbsp; &amp;nbsp;&amp;nbsp; High School&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Some College&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the best way to go about this?&amp;nbsp; Is there a way to do this via formatting?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 24 Mar 2020 15:27:11 GMT</pubDate>
    <dc:creator>Whitlea</dc:creator>
    <dc:date>2020-03-24T15:27:11Z</dc:date>
    <item>
      <title>Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634454#M188301</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable that reflect education level.&amp;nbsp; I would like to convert this variable to numeric and then tell SAS I want to highest level of education per person.&amp;nbsp; As of now, all levels of education are showing up per person and are character i.e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Education&lt;/P&gt;&lt;P&gt;0000 &amp;nbsp; &amp;nbsp;&amp;nbsp; High School&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Associates&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bachelors&lt;/P&gt;&lt;P&gt;0001 &amp;nbsp; &amp;nbsp;&amp;nbsp; High School&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Some College&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the best way to go about this?&amp;nbsp; Is there a way to do this via formatting?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 15:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634454#M188301</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2020-03-24T15:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634463#M188305</link>
      <description>&lt;P&gt;Best way is to create a custom informat. Make a comprehensive list of values in "Education", bring them into order, and assign numeric values in your proc informat code.&lt;/P&gt;
&lt;P&gt;Alternatively, you can create a dataset that can be used as CNTLIN dataset in proc format. Use TYPE "I" for this.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 15:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634463#M188305</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-24T15:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634466#M188307</link>
      <description>&lt;P&gt;Yes, use an informat and a format. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue edLevelIn (JUST UPCASE)
"HIGH SCHOOL" = 1
"ASSOCIATES" = 2
"BACHELORS" = 3
other = 0;
value edLevel
1 = "High School"
2 = "Associates"
3 = "Bachelors"
other = "Unknown";
run;

data test;
input ID  Education &amp;amp; :edLevelIn.;
format Education edLevel. id z4.0;
datalines;
0000   High School
0000    Associates 
0000    Bachelors
0001      High School
0001      Some College
;

proc print data=test noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Mar 2020 15:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634466#M188307</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-03-24T15:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634467#M188308</link>
      <description>&lt;P&gt;You have a couple of issues. First the character to numeric.&lt;/P&gt;
&lt;P&gt;I suspect we did not see all of the character values so this is incomplete but code similar to:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   select (education);
	 when ('High School') EdNum=1;
	 when ('Some College') EdNum=2;
	 when ('Associates') EdNum=3;
	 when ('Bachelors') EdNum=4;
	 otherwise put "WARNING: Unexpected value of education: " education;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;Select is an option to writing a whole bunch of If/Then/Else assignments. The comparison value must be exactly the same, case and all, to the values of your variable. The numeric value to assign is up to you.&lt;/P&gt;
&lt;P&gt;You can sort the data based on ID and the numeric value to get things in increasing (sort of) education level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next part depends on what your actual data looks like and are you looking for a report or a data set or what. Reports are what people read, data sets are for further manipulation. Also, if you any other other variables involved what needs to be done with them will affect the choices at this point.&lt;/P&gt;
&lt;P&gt;So if there are other variables involved you need to provide examples and what the final result should be.&lt;/P&gt;
&lt;P&gt;If the only thing involved is the ID and education level you can use any of the tools that involve the MAX of the numeric variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such as:&lt;/P&gt;
&lt;PRE&gt;Proc means data=want max;
   class id;
   var ednum;
run;&lt;/PRE&gt;
&lt;P&gt;but an example of what you expect the output to look like is a good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 16:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634467#M188308</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-24T16:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634814#M188420</link>
      <description>&lt;P&gt;For now I am just trying to create a data set where I can pull the highest level of education for each individual.&amp;nbsp; This was helpful and quick!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 16:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/634814#M188420</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2020-03-25T16:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/635910#M188860</link>
      <description>&lt;P&gt;Now that I have ednum the way that I want it, I would like the n and percentage of each level but only using the highest level of education per person.&amp;nbsp; Is there a way to do this in tabulate or freq? I have attached an example of what I would like to do, only this table includes all education levels. Hope this makes sense!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 18:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/635910#M188860</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2020-03-30T18:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/635940#M188867</link>
      <description>&lt;P&gt;First find the maximum per person. Then summarize.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway ;
  class person;
  var ednum;
  output out=want max=highest_ednum;
run;
proc freq data=want;
  tables highest_ednum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 19:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/635940#M188867</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-30T19:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/635992#M188877</link>
      <description>&lt;P&gt;This is exactly what I needed! Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 20:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/635992#M188877</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2020-03-30T20:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/636005#M188880</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s data step in the beginning of this post helped me to convert and order my data and also is a solution to this post.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 22:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/636005#M188880</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2020-03-30T22:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/636021#M188884</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/133143"&gt;@Whitlea&lt;/a&gt;, the name is &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, not edwards .&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 21:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/636021#M188884</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-03-30T21:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric then ordering and sorting it SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/636026#M188886</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/133143"&gt;@Whitlea&lt;/a&gt;, the name is &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, not edwards .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In a not quite strange twist of fate &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/133143"&gt;@Whitlea&lt;/a&gt; and I worked in the same shop so she knows my real name&lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt; and the w is for edward...&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 21:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric-then-ordering-and-sorting-it-SAS/m-p/636026#M188886</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-30T21:55:34Z</dc:date>
    </item>
  </channel>
</rss>

