<?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: converting a character data with colon to numeric data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525924#M143118</link>
    <description>&lt;P&gt;Have you tried wrapping with double quotes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;if hc_education in ("&lt;/SPAN&gt;&lt;STRONG&gt;I received a graduate degree or studied beyond a&lt;EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;bachelor's&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;degree","Associate's degree","Bachelor's degree","Graduate degree'')&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value has embedded single quote, wrap it with double quotes and vice versa&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jan 2019 22:30:19 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-09T22:30:19Z</dc:date>
    <item>
      <title>converting a character data with colon to numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525921#M143117</link>
      <description>&lt;P&gt;Hello-,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have this data where the observations are in character with colon in the names:&lt;/P&gt;
&lt;TABLE width="278"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD rowspan="2" width="278"&gt;
&lt;P&gt;&lt;STRONG&gt;hc_education&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Associate's degree&lt;/EM&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;&lt;EM&gt;Bachelor's degree&lt;/EM&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;Graduate degree&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;High school diploma/GED&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I attended 12th grade but did not receive a diploma&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed 10th grade (11 years of school)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed 11th grade (12 years of school)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed 6th grade (7 years of school)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed 9th grade (10 years of school)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed high school and graduated or received a GED (13 years of school)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed less than 6th grade (less than 7 years of school)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I completed some college or received an associate's degree&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I received a bachelor's degree (4 years of college)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;I received a graduate degree or studied beyond a bachelor's degree&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;Less than high school&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;Some college&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="278"&gt;Frequency Missing = 9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of the observations such as :&amp;nbsp; Associate's degree , Bachelor's degree etc have colon (') before s. Once I apply this code to change this to number:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data first1;&lt;BR /&gt;set BMII;&lt;BR /&gt;if hc_education in ('I attended 12th grade but did not receive a diploma','I completed 10th grade (11 years of school)', &lt;BR /&gt;'I completed 11th grade (12 years of school)','I completed 6th grade (7 years of school)','I completed 9th grade (10 years of school)',&lt;BR /&gt;'I completed less than 6th grade (less than 7 years of school)','Less than high school') then edu=1; else if hc_education in &lt;BR /&gt;('I completed high school and graduated or received a GED (13 years of school)','High school diploma/GED', 'Some college')then edu=2;&lt;BR /&gt;else if hc_education in ('&lt;STRONG&gt;I received a graduate degree or studied beyond a&lt;EM&gt; bachelor's&lt;/EM&gt; degree','Associate's degree','Bachelor's degree','Graduate degree'')&lt;/STRONG&gt;&lt;BR /&gt;then edu=3;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;I got error:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;104 else if hc_education in ('I received a graduate degree or studied beyond a bachelor's&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; -----------------------------------------------------------&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;---&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;----------&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;---&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; 49 49&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;49&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;49&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; -&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; 22&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; -&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; 76&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;104! degree','Associate's degree','Bachelor's degree','Graduate degree'')&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; release. Inserting white space between a quoted string and the succeeding identifier&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; is recommended.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; a datetime constant, a missing value, iterator, (, ), ','.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;105 then edu=3;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please How do I fix this in the code. I cannot change in the Data set.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 22:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525921#M143117</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2019-01-09T22:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: converting a character data with colon to numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525924#M143118</link>
      <description>&lt;P&gt;Have you tried wrapping with double quotes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;if hc_education in ("&lt;/SPAN&gt;&lt;STRONG&gt;I received a graduate degree or studied beyond a&lt;EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;bachelor's&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;degree","Associate's degree","Bachelor's degree","Graduate degree'')&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value has embedded single quote, wrap it with double quotes and vice versa&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 22:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525924#M143118</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-09T22:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: converting a character data with colon to numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525925#M143119</link>
      <description>You should try using a format instead. It makes things like this much easier to work with.</description>
      <pubDate>Wed, 09 Jan 2019 22:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-a-character-data-with-colon-to-numeric-data/m-p/525925#M143119</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-09T22:30:22Z</dc:date>
    </item>
  </channel>
</rss>

