<?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: combine datasets if different datatypes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902018#M356433</link>
    <description>Your sample program would work except for two small errors.&lt;BR /&gt;&lt;BR /&gt;First, the logic for con_to_numeric creates two variables both named ID.  That's not allowed.  To fix that, add before the RENAME statement:&lt;BR /&gt;&lt;BR /&gt;drop id;&lt;BR /&gt;&lt;BR /&gt;Second, your last SET statement reads the wrong data sets.  It should say:&lt;BR /&gt;&lt;BR /&gt;set dsn1 con_to_numeric;</description>
    <pubDate>Wed, 08 Nov 2023 10:14:54 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2023-11-08T10:14:54Z</dc:date>
    <item>
      <title>combine datasets if different datatypes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902017#M356432</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn1;
input id score;
datalines;
1 22
1 55
2 55
4  .
4  44
;
run;


data dsn2;
input id $ score;
datalines;
6 55 
6  .
7 12
8  44
9  66
9 14
;
run;

data con_to_numeric;
set  dsn2;
id1=input(id ,best8.);
rename id1= id;
run;

data combine;
set dsn2 con_to_numeric;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;how to combine dataset if different datatypes&amp;nbsp; in datastep and proc sql&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 10:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902017#M356432</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-11-08T10:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: combine datasets if different datatypes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902018#M356433</link>
      <description>Your sample program would work except for two small errors.&lt;BR /&gt;&lt;BR /&gt;First, the logic for con_to_numeric creates two variables both named ID.  That's not allowed.  To fix that, add before the RENAME statement:&lt;BR /&gt;&lt;BR /&gt;drop id;&lt;BR /&gt;&lt;BR /&gt;Second, your last SET statement reads the wrong data sets.  It should say:&lt;BR /&gt;&lt;BR /&gt;set dsn1 con_to_numeric;</description>
      <pubDate>Wed, 08 Nov 2023 10:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902018#M356433</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-11-08T10:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: combine datasets if different datatypes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902036#M356442</link>
      <description>&lt;P&gt;You can append data sets using the OUTER UNION CORRESPONDING statement in PROC SQL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In work.ds2, the id column is converted from character to numeric using the input() function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table work.want as 
  select *
  from dsn1
    outer union corresponding
  select input(id,1.) as id
  ,		 score
  from dsn2
 order by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2023 12:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902036#M356442</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2023-11-08T12:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: combine datasets if different datatypes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902037#M356443</link>
      <description>&lt;P&gt;Do it in one step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set
  dsn1 (
    in=in1
    rename=(id=id1)
  )
  dsn2
;
if in1 then id = input(id1.best.);
drop id1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But with ID's you should convert everything to character with formatting as documented for your data.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 12:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902037#M356443</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-11-08T12:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: combine datasets if different datatypes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902768#M356773</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/218062"&gt;@ChanceTGardener&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your solution&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 10:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-datasets-if-different-datatypes/m-p/902768#M356773</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-11-13T10:36:24Z</dc:date>
    </item>
  </channel>
</rss>

