<?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: Merging multiple datasets using macro, without having same varialbes in them in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590098#M14995</link>
    <description>&lt;P&gt;Perhaps you just need to change the setting for the&amp;nbsp;&lt;SPAN&gt;DKRICOND option?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Why not have your macro generate code like this?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dkricond=nowarn;
data want ;
  set member_1(keep=&amp;amp;var_list)
      member_2(keep=&amp;amp;var_list)
   ...
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Sep 2019 16:16:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-09-19T16:16:29Z</dc:date>
    <item>
      <title>Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590080#M14990</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dataset_list = member_1 member_2 member_3 member_4 member_5;

%let var_list = member_name coverage_st_dt coverage_end_dt policy_ext;




%macro file_process;
%let word_cnt = %sysfunc(countW(&amp;amp;dataset_list));
%do i = 1 %to &amp;amp;word_cnt;

data dataset_1;

set datamart.%qscan(%bquote(&amp;amp;dataset_list),&amp;amp;i)(keep= &amp;amp;var_list );
proc append base= dataset_2 data= dataset_1;
run;
%end;


%mend file_process;

%file_process;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on merging mutliple datasets into one dataset using a single macro function. I'm passing the required datasets and variables names using a macro variable. this is working fine, but in couple of datasets i don't have all the variables that I'm passing.&amp;nbsp; code is failing here. below is the code i developed so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is to merge the datasets, eventhough all the datasets doesn't have same variables.&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 15:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590080#M14990</guid>
      <dc:creator>sasuser_221</dc:creator>
      <dc:date>2019-09-19T15:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590087#M14992</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro file_process;

data dataset_2;
set
%do i = 1 %to %sysfunc(countw(&amp;amp;dataset_list.));
  datamart.%scan(&amp;amp;dataset_list.,&amp;amp;i.)
%end;
;
keep &amp;amp;var_list.;
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 15:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590087#M14992</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-19T15:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590089#M14993</link>
      <description>&lt;P&gt;Any reason not to use the shortcut operator?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set datamart.member_1 - datamart.member_5;

keep &amp;amp;var_list;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PROC APPEND cannot add new variables. In general, I would recommend creating a master data set that has the types and all the variables you want and then append into that data set. I usually use PROC SQL to create those empty tables, though if you have a table that is like that you can make the skeleton table easily using obs=0 option. Then use the skeleton table in your PROC APPEND as your base. I'm just labeling it skeleton for illustration purposes you can call it whatever&amp;nbsp; you'd like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*make skeleton;

data skeleton;
set tableProperties (obs=0);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 16:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590089#M14993</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-19T16:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590098#M14995</link>
      <description>&lt;P&gt;Perhaps you just need to change the setting for the&amp;nbsp;&lt;SPAN&gt;DKRICOND option?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Why not have your macro generate code like this?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dkricond=nowarn;
data want ;
  set member_1(keep=&amp;amp;var_list)
      member_2(keep=&amp;amp;var_list)
   ...
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 16:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590098#M14995</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-19T16:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590117#M14996</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288840"&gt;@sasuser_221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My requirement is to merge the datasets, eventhough all the datasets doesn't have same variables.&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general SAS terms 'MERGE' means a side-by-side combination, usually on a common value(s).&lt;/P&gt;
&lt;P&gt;data like:&lt;/P&gt;
&lt;P&gt;Name age&lt;/P&gt;
&lt;P&gt;John&amp;nbsp;&amp;nbsp; 16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name&amp;nbsp; grade&lt;/P&gt;
&lt;P&gt;John&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and a merge results in&lt;/P&gt;
&lt;P&gt;Name age grade&lt;/P&gt;
&lt;P&gt;John&amp;nbsp;&amp;nbsp; 16&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you mention append that would be a vertical stacking or use of SET statements in a data step.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 16:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590117#M14996</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-19T16:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590366#M15027</link>
      <description>&lt;P&gt;Try add an option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base= dataset_2 data= dataset_1   force  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Sep 2019 12:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/590366#M15027</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-20T12:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/602245#M16803</link>
      <description>&lt;P&gt;Thank you for your reply and its working now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting results as expected, but with warning sometimes.&lt;/P&gt;&lt;P&gt;Is there any other possible way to get rid of the warnings.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 22:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/602245#M16803</guid>
      <dc:creator>sasuser_221</dc:creator>
      <dc:date>2019-11-06T22:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/602330#M16809</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288840"&gt;@sasuser_221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your reply and its working now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm getting results as expected, but with warning sometimes.&lt;/P&gt;
&lt;P&gt;Is there any other possible way to get rid of the warnings.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When the data step creates WARNINGs, it is because you have variables in later datasets with a longer defined length than they had in the first dataset where they were encountered, as this might lead to truncation of data.&lt;/P&gt;
&lt;P&gt;You have two options:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;find the maximum defined length of all variables in all your datasets; can be retrieved from dictionary.columns. Use this to create a length statement that you place &lt;EM&gt;before&lt;/EM&gt; the set.&lt;/LI&gt;
&lt;LI&gt;make sure you have a reliable data import process. Stop using proc import, read your external data with data steps where you take complete control over column attributes, according to the specifications you got along with the data. Then a sepcific variable will be defined with a consistent length across all your datasets.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The second option is to be preferred by orders of magnitude. Really. I mean it.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 06:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/602330#M16809</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-07T06:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603379#M16937</link>
      <description>&lt;P&gt;I'm getting below warning&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: The variable var1 in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to overcome this type of warning?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 22:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603379#M16937</guid>
      <dc:creator>sasuser_221</dc:creator>
      <dc:date>2019-11-11T22:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603380#M16938</link>
      <description>&lt;P&gt;Check your DROP, KEEP/RENAME statements to see if any reference a variable that no longer exists for some reason.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can comment out each one and run it and see which generates the error and then fix that one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288840"&gt;@sasuser_221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm getting below warning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: The variable var1 in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to overcome this type of warning?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 22:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603380#M16938</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-11T22:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603383#M16940</link>
      <description>&lt;P&gt;i'm using a loop to iterate through multiple datasets and a macro variable with all the variable that I need from the datasets.&lt;/P&gt;&lt;P&gt;the catch is not all datasets have all the variables that I'm pulling, that is why I'm getting a warning.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 22:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603383#M16940</guid>
      <dc:creator>sasuser_221</dc:creator>
      <dc:date>2019-11-11T22:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603389#M16942</link>
      <description>If not all datasets have the variables, then you have the warning correctly. You can either turn off the warning or live with it if you don't want to change the code to adapt for the variables that may not exist.</description>
      <pubDate>Mon, 11 Nov 2019 22:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603389#M16942</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-11T22:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603393#M16943</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288840"&gt;@sasuser_221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm getting below warning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: The variable var1 in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to overcome this type of warning?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Set the DKRICOND option to NOWARN.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lesysoptsref&amp;amp;docsetTarget=p11ksgdhjx7369n1dpiry84z7gjn.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lesysoptsref&amp;amp;docsetTarget=p11ksgdhjx7369n1dpiry84z7gjn.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 22:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603393#M16943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-11T22:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets using macro, without having same varialbes in them</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603489#M16956</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288840"&gt;@sasuser_221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm getting below warning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: The variable var1 in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to overcome this type of warning?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code I gave you (and which you accepted as solution) CAN NOT cause this WARNING, as it does not have a drop, keep or rename.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 12:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-multiple-datasets-using-macro-without-having-same/m-p/603489#M16956</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-12T12:00:31Z</dc:date>
    </item>
  </channel>
</rss>

