<?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 with a %do_over macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788162#M251940</link>
    <description>&lt;P&gt;You have 2 arguments in your macro:&amp;nbsp;&lt;STRONG&gt;symbols&lt;/STRONG&gt; as positional argument and&amp;nbsp;&lt;STRONG&gt;values&lt;/STRONG&gt; as named argument but you don't refer to the last one.&lt;/P&gt;
&lt;P&gt;My suggestion is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let symbols=ALGO AVAX AXS BNB BTC LINK ATOM DOGE ETH LTC NEAR OKB DOT MATIC XRP ADA SOL XLM LUNA UNI;

data Projekt.prices;
   merge 
%doi=1 %to %sysfunc(countw(&amp;amp;symbols));
    %let var=%scan(&amp;amp;symbols,&amp;amp;i);
    %do; &amp;amp;var (rename=(&amp;amp;var=%quote(&amp;amp;var))) %end;
%end;
  ;
 drop marketcap totalvolume;  
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Jan 2022 18:21:51 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2022-01-03T18:21:51Z</dc:date>
    <item>
      <title>Merging multiple datasets with a %do_over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788154#M251933</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I am using SAS 9.4&lt;/P&gt;&lt;P&gt;I have 20 datasets consisting of the same number of variables (date price, marketcap and totalvolume) and observations (365) regarding historical data for 20 different cryptocurrencies. What i am trying to do, is merge them into one dataset containing only date and price of every currency. I am able to achive this result manualy using this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data Projekt.prices;
merge 
	Projekt.BTC (rename=(price=BTC))
	Projekt.XRP (rename=(price=XRP))
	Projekt.XRP (rename=(price=ALGO))
	Projekt.AVAX (rename=(price=AVAX))
	Projekt.AXS (rename=(price=AXS))
	Projekt.BNB (rename=(price=BNB))
	Projekt.LINK (rename=(price=LINK))
	Projekt.ATOM (rename=(price=ATOM))
	Projekt.DOGE (rename=(price=DOGE))
	Projekt.ETH (rename=(price=ETH))
	Projekt.LTC (rename=(price=LTC))
	Projekt.NEAR (rename=(price=NEAR))
	Projekt.OKB (rename=(price=OKB))
	Projekt.DOT (rename=(price=DOT))
	Projekt.MATIC (rename=(price=MATIC))
	Projekt.XRP (rename=(price=XRP))
	Projekt.ADA (rename=(price=ADA))
	Projekt.SOL (rename=(price=SOL))
	Projekt.XLM (rename=(price=XLM))
	Projekt.LUNA (rename=(price=LUNA))
	Projekt.UNI (rename=(price=UNI));
by date;
label BTC = "BTC";
label XRP = "XRP";
label ALGO = "ALGO";
label AVAX = "AVAX";
label AXS = "AXS";
label BNB = "BNB";
label LINK = "LINK";
label ATOM = "ATOM";
label DOGE = "DOGE";
label ETH = "ETH";
label LTC = "LTC";
label NEAR = "NEAR";
label OKB = "OKB";
label DOT = "DOT";
label MATIC = "MATIC";
label XRP = "XRP";
label ADA = "ADA";
label SOL = "SOL";
label XLM = "XLM";
label LUNA = "LUNA";
label UNI = "UNI";
drop marketcap totalvolume;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I would like to improve my solution by using a %do_over community macro, so I tried this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%ARRAY(Symbols, VALUES=ALGO AVAX AXS BNB BTC LINK ATOM DOGE ETH LTC NEAR OKB DOT MATIC XRP ADA SOL XLM LUNA UNI);
DATA Projekt.prices2;
MERGE %DO_OVER(Symbols, PHRASE=Projekt.? (rename=(price=?)));
BY date;
LABEL %DO_OVER(Symbols, PHRASE=?="?";);
DROP marketcap totalvolume;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it only works for the first dataset (ALGO) and then I get a Note in the log:&lt;/P&gt;&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by:
(Line):(Column).
1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1 1:1
1:1 1:1 1:1 1:1&lt;/PRE&gt;&lt;P&gt;The table I get as a result looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="problem.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67085i4C307656DACCBA23/image-size/large?v=v2&amp;amp;px=999" role="button" title="problem.PNG" alt="problem.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And what it should look like is this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nieproblem.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67086iE8F94B5E07C57407/image-size/large?v=v2&amp;amp;px=999" role="button" title="nieproblem.PNG" alt="nieproblem.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate any suggestions... Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 17:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788154#M251933</guid>
      <dc:creator>jan_bielski</dc:creator>
      <dc:date>2022-01-03T17:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets with a %do_over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788162#M251940</link>
      <description>&lt;P&gt;You have 2 arguments in your macro:&amp;nbsp;&lt;STRONG&gt;symbols&lt;/STRONG&gt; as positional argument and&amp;nbsp;&lt;STRONG&gt;values&lt;/STRONG&gt; as named argument but you don't refer to the last one.&lt;/P&gt;
&lt;P&gt;My suggestion is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let symbols=ALGO AVAX AXS BNB BTC LINK ATOM DOGE ETH LTC NEAR OKB DOT MATIC XRP ADA SOL XLM LUNA UNI;

data Projekt.prices;
   merge 
%doi=1 %to %sysfunc(countw(&amp;amp;symbols));
    %let var=%scan(&amp;amp;symbols,&amp;amp;i);
    %do; &amp;amp;var (rename=(&amp;amp;var=%quote(&amp;amp;var))) %end;
%end;
  ;
 drop marketcap totalvolume;  
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Jan 2022 18:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788162#M251940</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2022-01-03T18:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets with a %do_over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788165#M251941</link>
      <description>&lt;P&gt;May I suggest you &lt;FONT color="#FF0000"&gt;show us&lt;/FONT&gt; the %ARRAY and %DO_OVER macros?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I also strongly suggest that you show us the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; log for this batch of code, and that you should not show us the ERRORs WARNINGs and NOTEs in the log detached from the code.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 18:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788165#M251941</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-03T18:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets with a %do_over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788167#M251942</link>
      <description>Thank you so much for your help! Works perfectly.</description>
      <pubDate>Mon, 03 Jan 2022 18:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788167#M251942</guid>
      <dc:creator>jan_bielski</dc:creator>
      <dc:date>2022-01-03T18:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple datasets with a %do_over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788169#M251943</link>
      <description>Thank you very much for your reply! Fortunately the solution proposed by Shmuel worked perfectly, but of course I will keep your suggestions in mind. Cheers!</description>
      <pubDate>Mon, 03 Jan 2022 19:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-datasets-with-a-do-over-macro/m-p/788169#M251943</guid>
      <dc:creator>jan_bielski</dc:creator>
      <dc:date>2022-01-03T19:01:40Z</dc:date>
    </item>
  </channel>
</rss>

