<?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 How to convert a character to numeric value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743755#M232930</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having such a horrible time right now. I imported my own data set from excel from qualtrics and I am getting a bunch of error messages. I noticed that when I click on my data set sas7bdat format, I noticed there is character instead of numeric like the other data sets.&lt;/P&gt;&lt;P&gt;I am also getting ERROR: variable age in list does not match type prescribed for this list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to run descriptive statistics on age, gender, and race.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate all your help so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my code&lt;/P&gt;&lt;PRE&gt;libname classdat "/home/u47052435/ClassDat";&lt;BR /&gt;&lt;BR /&gt;proc contents data=group4homelessness;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Basic descriptive statistics for scale variable "age"&lt;BR /&gt;proc means data= classdat.group4homelessness&lt;BR /&gt;var age:&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Additional statistics for scale  "age";&lt;BR /&gt;proc means data=classdat.group4homelessness n mean median mode min max&lt;BR /&gt;stddev range qrange nmiss;&lt;BR /&gt;var age;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 May 2021 04:37:32 GMT</pubDate>
    <dc:creator>m231</dc:creator>
    <dc:date>2021-05-26T04:37:32Z</dc:date>
    <item>
      <title>How to convert a character to numeric value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743755#M232930</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having such a horrible time right now. I imported my own data set from excel from qualtrics and I am getting a bunch of error messages. I noticed that when I click on my data set sas7bdat format, I noticed there is character instead of numeric like the other data sets.&lt;/P&gt;&lt;P&gt;I am also getting ERROR: variable age in list does not match type prescribed for this list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to run descriptive statistics on age, gender, and race.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate all your help so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my code&lt;/P&gt;&lt;PRE&gt;libname classdat "/home/u47052435/ClassDat";&lt;BR /&gt;&lt;BR /&gt;proc contents data=group4homelessness;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Basic descriptive statistics for scale variable "age"&lt;BR /&gt;proc means data= classdat.group4homelessness&lt;BR /&gt;var age:&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Additional statistics for scale  "age";&lt;BR /&gt;proc means data=classdat.group4homelessness n mean median mode min max&lt;BR /&gt;stddev range qrange nmiss;&lt;BR /&gt;var age;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 04:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743755#M232930</guid>
      <dc:creator>m231</dc:creator>
      <dc:date>2021-05-26T04:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a character to numeric value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743758#M232931</link>
      <description>&lt;P&gt;How are you bringing in the Excel data?&amp;nbsp; There are several ways this might occur:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Via a Libname using the XLSX engine if you have SAS/Access on your machine.&lt;/LI&gt;
&lt;LI&gt;Via a Proc IMPORT&lt;/LI&gt;
&lt;LI&gt;Via SAS Enterprise Guide which has a very nice facility for importing Excel&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Enterprise Guide might be the easiest, but all of these can be configured one way or another so that you can specify the data type when you import.&amp;nbsp; I would delete the data and re-import unless there is an overriding reason not to do so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also write a data step to convert things.&amp;nbsp; It might be easier to just re-import the data though.&amp;nbsp; Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA  Reconfigured_Data (RENAME=(Numeric_Var=Old_Var));
    SET  Incorrect_Type_Data;

    Numeric_Var = INPUT(Old_Var, 8.);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The trick here is that 8. Informat.&amp;nbsp; You have to get the right length for your data.&amp;nbsp; Again, it might be easier to just re-import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know of a way to change the data type in a statistical procedure itself.&amp;nbsp; You generally need to fix the data before running the Proc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 05:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743758#M232931</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-26T05:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a character to numeric value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743760#M232933</link>
      <description>&lt;P&gt;Hi Jim, I am adding the excel file through libname.&lt;/P&gt;&lt;P&gt;I tried generating the code you sent and I am getting ERROR: FILE WORK.INCORRECT_TYPE_DATA.DATA does not exist.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 05:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743760#M232933</guid>
      <dc:creator>m231</dc:creator>
      <dc:date>2021-05-26T05:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a character to numeric value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743762#M232935</link>
      <description>&lt;P&gt;Yes, I just used that as an illustrative name.&amp;nbsp; You have to change my code to the dataset names.&amp;nbsp; The same applies to the variables.&amp;nbsp; You have to substitute the real names for the names I used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 05:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743762#M232935</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-26T05:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a character to numeric value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743763#M232936</link>
      <description>&lt;P&gt;Looking at your code, the real dataset name I think is&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;classdat.group4homelessness&lt;/PRE&gt;
&lt;P&gt;and the real variable name is&lt;/P&gt;
&lt;PRE&gt;var age;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was just trying to illustrate a principle.&amp;nbsp; You still have to do a little work.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JIm&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 05:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-numeric-value/m-p/743763#M232936</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-26T05:53:26Z</dc:date>
    </item>
  </channel>
</rss>

