<?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: Data conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153751#M298532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Examples of the values involved would help. You cannot change an existing variables data type.&lt;/P&gt;&lt;P&gt;Best is to read the data with an appropriate INFORMAT from the beginning.&lt;/P&gt;&lt;P&gt;Afterwards you can either create a new variable or go through some renaming to get the same variable name associated with a numeric value.&lt;/P&gt;&lt;P&gt;The basic approach is in a data step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NumericVar = input(CharacterVar,&amp;lt;numericformat.&amp;gt;); The appropriate numeric format may differ for different values though BEST will work for many cases. Suffix the BEST with the largest number of significant digits in your data.&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Numericvar = input(CharacterVar, best12. ); /* NOTE: the period at the end of the BEST12. is required to let SAS know this is an Informat*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Feb 2015 22:34:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-02-04T22:34:44Z</dc:date>
    <item>
      <title>Data conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153750#M298531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Can anyone tell me how to convert character variable to numeric variable.?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Feb 2015 21:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153750#M298531</guid>
      <dc:creator>preetham_vr386_gmail_com</dc:creator>
      <dc:date>2015-02-04T21:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153751#M298532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Examples of the values involved would help. You cannot change an existing variables data type.&lt;/P&gt;&lt;P&gt;Best is to read the data with an appropriate INFORMAT from the beginning.&lt;/P&gt;&lt;P&gt;Afterwards you can either create a new variable or go through some renaming to get the same variable name associated with a numeric value.&lt;/P&gt;&lt;P&gt;The basic approach is in a data step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NumericVar = input(CharacterVar,&amp;lt;numericformat.&amp;gt;); The appropriate numeric format may differ for different values though BEST will work for many cases. Suffix the BEST with the largest number of significant digits in your data.&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Numericvar = input(CharacterVar, best12. ); /* NOTE: the period at the end of the BEST12. is required to let SAS know this is an Informat*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Feb 2015 22:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153751#M298532</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-04T22:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153752#M298533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The question is....&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;1. &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;Create&amp;nbsp; 2 DATA set named employee_data1 and employee_data2. Each data contains 4 variables – Gender, educ, Jobcat &amp;amp; Salary . employee_data1 store only MALE obs having Educ ranges from 12 to 15 and jobcat must be 1&amp;nbsp; AND employee_data2 store only FEMALE obs having Educ ranges from 8 to 12 , jobcat must be 1 and salary &amp;gt; $10,000&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;The data of Excel file is......&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&lt;IMG alt="Untitled.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9040_Untitled.png" width="450" /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;The problem Iam having is Iam unable to add salaries corresponding to males and females... The problem I think is due to the dollar sign and comma in the salary variable. I tried to convert these character variable to numeric variable by using input statement as shown below.... but still I am getting errors..&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-size: 12.0pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data employee_data1 employee_data2;&lt;/P&gt;&lt;P&gt;set Employee1( keep= gender educ jobcat salary);&lt;/P&gt;&lt;P&gt;input( salary, dollar7.);&lt;/P&gt;&lt;P&gt;if ( gender='m' AND Educ IN( 12 13 14 15) AND jobcat=1) then output bittu.employee_data1;&lt;/P&gt;&lt;P&gt;if ( gender='f' AND Educ IN( 8 9 10 11 12) AND jobcat=1 AND salary &amp;gt; 10,000 ) then output bittu.employee_data2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 16:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153752#M298533</guid>
      <dc:creator>preetham_vr386_gmail_com</dc:creator>
      <dc:date>2015-02-05T16:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Data conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153753#M298534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It might be helpful to provide the example data as it looks in a plain text file or in a SAS printout, as Excel may apply formatting that makes it look different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your program fragment, you have at least two errors that will make it not work, even if the data are as they appear in the Excel screenshot.&lt;/P&gt;&lt;P&gt;1. the value returned from the input function needs to be assigned to a variable, like&lt;/P&gt;&lt;P&gt;salary2 = input(salary, dollar7.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. when you compare the salary to a particular number in the if statement, that number cannot have commas in it. For example (leaving out the other parts of your if statement for clarity), you want something like:&lt;/P&gt;&lt;P&gt;if salary2 &amp;gt; 10000 then .... ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 18:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153753#M298534</guid>
      <dc:creator>Erico</dc:creator>
      <dc:date>2015-02-05T18:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153754#M298535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Erico.. &lt;/P&gt;&lt;P&gt;I finally got my required data..&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 21:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-conversion/m-p/153754#M298535</guid>
      <dc:creator>preetham_vr386_gmail_com</dc:creator>
      <dc:date>2015-02-05T21:07:44Z</dc:date>
    </item>
  </channel>
</rss>

