<?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: How to solve numeric and character issue when appending data in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739669#M28993</link>
    <description>Can you please give me an example on how to do that? Sorry, I dont have a lot of skills in SAS</description>
    <pubDate>Thu, 06 May 2021 22:25:29 GMT</pubDate>
    <dc:creator>hjjijkkl</dc:creator>
    <dc:date>2021-05-06T22:25:29Z</dc:date>
    <item>
      <title>How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739663#M28988</link>
      <description>&lt;P&gt;I am appending two dataset and i am getting this error below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Variable age has been defined as both character and numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the problem is one of the dataset has missing value and the other data has a numeric value for the same variable (age). what is the best way to solve this issue?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is an example of what the two data look like.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 1&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="312"&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="312"&gt;
&lt;P&gt;Sex&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="312"&gt;
&lt;P&gt;age&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="312"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="312"&gt;
&lt;P&gt;F&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="312"&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="312"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="312"&gt;
&lt;P&gt;F&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="312"&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table2&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="234"&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;Sex&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;age&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;Education&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="234"&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;M&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;33&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;BA&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="234"&gt;
&lt;P&gt;6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;F&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;67&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="234"&gt;
&lt;P&gt;PHD&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is what the data should look like after appending (Table1 and Table2)&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="122"&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="128"&gt;
&lt;P&gt;Sex&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;age&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;Education&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="122"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="128"&gt;
&lt;P&gt;F&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="122"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="128"&gt;
&lt;P&gt;F&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="122"&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="128"&gt;
&lt;P&gt;M&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;33&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;BA&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="122"&gt;
&lt;P&gt;6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="128"&gt;
&lt;P&gt;F&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;67&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="318"&gt;
&lt;P&gt;PHD&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 22:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739663#M28988</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-05-06T22:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739664#M28989</link>
      <description>You have to pre-process the data to ensure your types are correct. If you imported the data from CSV or text files you go back and fix it there. If you imported your data from a DB or Excel you have to manually go through a step to confirm them. For some, like in your post it's obvious but for others (like ID) it can be a decision. It's common to store ID as a character so that you never accidentally use it for mathematical calculations for example.</description>
      <pubDate>Thu, 06 May 2021 22:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739664#M28989</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-06T22:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739665#M28990</link>
      <description>the two data are already in SAS stored, I didn't import it.</description>
      <pubDate>Thu, 06 May 2021 22:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739665#M28990</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-05-06T22:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739666#M28991</link>
      <description>Then it's similar to Excel/DB you need to go through and standardize your types. First you have to make a decision on the appropriate types and then you have to make them that, then you can merge them. Data cleaning is a pain but necessary.</description>
      <pubDate>Thu, 06 May 2021 22:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739666#M28991</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-06T22:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739668#M28992</link>
      <description>&lt;P&gt;If the data set with mistakenly typed character variable is always to be consider a numeric missing value, then you can use the DROP= parameter as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have (where=(sex='M') drop=_:) 
     girls (where=(sex='F') drop=age rename=(_age=age));
  set sashelp.class;
  _age='.';
run;

proc append base=have data=girls (drop=age);run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if the variable were not dropped, the proc append would fail with the message you report.&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 22:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739668#M28992</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-05-06T22:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739669#M28993</link>
      <description>Can you please give me an example on how to do that? Sorry, I dont have a lot of skills in SAS</description>
      <pubDate>Thu, 06 May 2021 22:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739669#M28993</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-05-06T22:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve numeric and character issue when appending data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739721#M29004</link>
      <description>&lt;P&gt;To append tables they must have same named columns of the same data type (in SAS either Char or Num).&lt;/P&gt;
&lt;P&gt;If you know that the data type should be numeric but in one of your data sets it's character then you could use code as below to convert the character string to numeric and store it in a new variable with the name you need for appending to another table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have_ageIsCharDataType;
  infile datalines truncover;
  input age :$10.;
  datalines;
.
12
25
 
.
40
abc
;

data want_ageIsNumDataType;
  set have_ageIsCharDataType(rename=(age=ageIsCharDataType));
  length age 8;
  age=input(ageIsCharDataType,?? best32.);
  drop ageIsCharDataType;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The ?? as part of the input statement will suppress any warnings. Any source string that can't get converted into a numerical value will become missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1620377319837.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59126iE68E4B139D1E4C73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1620377319837.png" alt="Patrick_0-1620377319837.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 08:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-solve-numeric-and-character-issue-when-appending-data/m-p/739721#M29004</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-05-07T08:48:52Z</dc:date>
    </item>
  </channel>
</rss>

