<?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: need to dynamically call all available SDTM domain (including SUPP) names into a macro parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/620098#M182162</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169529"&gt;@ssv&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generate a list of all data set names where a supp domain name matches a parent domain name, then go through the names in the list in a loop. Sort of like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;                                                                                                                                                                                                                                              
  select memname into :supplist separated by " " from dictionary.tables where libname = "WORK" and memname not eqt "SUPP"                                                                                                                                       
  and    memname in (select substr (memname, 5)  from dictionary.tables where libname = "WORK" and memname     eqt "SUPP")                                                                                                                                      
  ;                                                                                                                                                                                                                                                             
quit ;                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                
%macro combine (list=, dst=) ;                                                                                                                                                                                                                                  
  %local i ;                                                                                                                                                                                                                                                    
  %do i = 1 %to sysfunc (countw (&amp;amp;list)) ;                                                                                                                                                                                                                      
    %let in = %scan (&amp;amp;list, &amp;amp;i) ;                                                                                                                                                                                                                               
    proc sort data = &amp;amp;in out = &amp;amp;in ;                                                                                                                                                                                                                            
      by usubjid &amp;amp;in.seq ;                                                                                                                                                                                                                                      
    run ;                                                                                                                                                                                                                                                       
    proc sort data = supp&amp;amp;in  out = supp&amp;amp;in ;                                                                                                                                                                                                                   
      by usubjid idvarval qnam ;                                                                                                                                                                                                                                
    run ;                                                                                                                                                                                                                                                       
    proc transpose data = supp&amp;amp;in out = supp&amp;amp;in._ (drop = _:) ;                                                                                                                                                                                                 
      by usubjid idvarval ;                                                                                                                                                                                                                                     
      id qnam ;                                                                                                                                                                                                                                                 
      idlabel qlabel ;                                                                                                                                                                                                                                          
      var qval ;                                                                                                                                                                                                                                                
    run ;                                                                                                                                                                                                                                                       
    data supp&amp;amp;in._ (drop = idvarval) ;                                                                                                                                                                                                                          
      set supp&amp;amp;in._ ;                                                                                                                                                                                                                                           
      &amp;amp;in.seq = input (idvarval, best.) ;                                                                                                                                                                                                                       
    run ;                                                                                                                                                                                                                                                       
    proc sort data = supp&amp;amp;in._ ;                                                                                                                                                                                                                                
      by usubjid &amp;amp;in.seq ;                                                                                                                                                                                                                                      
    run ;                                                                                                                                                                                                                                                       
    data &amp;amp;in._merg ;                                                                                                                                                                                                                                            
      merge &amp;amp;in (in = _in) supp&amp;amp;in._ ;                                                                                                                                                                                                                          
      by usubjid &amp;amp;in.seq ;                                                                                                                                                                                                                                      
      if _in ;                                                                                                                                                                                                                                                  
    run ;                                                                                                                                                                                                                                                       
  %end ;                                                                                                                                                                                                                                                        
%mend ;                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                
%combine (list=&amp;amp;supplist)             
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This way, you don't have to call the same macro a bunch of times and/or determine which domains to use as an argument by eyeballing your library. Leave this tedious and error-prone work to the computer - you're using it anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Jan 2020 22:36:26 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2020-01-26T22:36:26Z</dc:date>
    <item>
      <title>need to dynamically call all available SDTM domain (including SUPP) names into a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/619763#M182033</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to merge SDTM parent domain with supp domain by using macro. Each time I call the macro I need to pass one SDTM domain name and create a &lt;STRONG&gt;New&lt;/STRONG&gt; dataset which is the merged dataset(Parent and Supp), Which is making me to call the macro multiple times and which is not dynamic. I need some help to make this macro dynamic which will automatically check and call all the domains available in my library and check if that domain has a SUPP domain or not, If there is a SUPP domain, then I want to merge Parent and SUPP domains and if there is no SUPP domain, it will keep the Parent domain as is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example: if I have DM, SE, SV, AE,&amp;nbsp; DS domains in my library. Macro need to dynamically call all these 5 available domains one by one &lt;STRONG&gt;automatically&lt;/STRONG&gt; available in that library&lt;STRONG&gt;. &lt;/STRONG&gt;As&amp;nbsp;DM, AE, DS will have SUPP domains, then it should merge Parent domain (Ex: DM) with SUPP domain (Ex: SUPPDM) into a new dataset named &lt;STRONG&gt;XX&lt;/STRONG&gt;_MERG (Ex: DM_MERG). If domain doesn't have SUPP domain (Ex: SE, SV), it should leave as is.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find my macro below and help to make it dynamic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;combine&lt;/STRONG&gt;(in=, out=, dst=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#333399"&gt; proc sort&lt;/FONT&gt; data=&amp;amp;in.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;out=&amp;amp;in.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; by usubjid &amp;amp;in.seq;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;proc sort data=supp&amp;amp;in.&amp;nbsp; out=supp&amp;amp;in.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by usubjid idvarval qnam;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;proc transpose data=supp&amp;amp;in. out=supp&amp;amp;in._ (drop=_NAME_ _LABEL_);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; by usubjid idvarval;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id qnam;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; idlabel qlabel;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var qval;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data supp&amp;amp;in._;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set supp&amp;amp;in._;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;in.seq=input(idvarval, best.);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;drop idvarval;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; proc sort data=supp&amp;amp;in._;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; by usubjid &amp;amp;in.seq;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data &amp;amp;out.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; merge &amp;amp;in.(in=a) supp&amp;amp;in._;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; by usubjid &amp;amp;in.seq;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if a;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;%mend;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of calling macro multiple times with each domain name per call &lt;STRONG&gt;as shown below&lt;/STRONG&gt;. I want macro to check all the domains available in my library and call them one by one&amp;nbsp; if it has SUPP domain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%combine(in=dm, out=dm_merg);&lt;BR /&gt;%combine(in=ae, out=ae_merg);&lt;BR /&gt;%combine(in=ds, out=ds_merg);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 04:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/619763#M182033</guid>
      <dc:creator>ssv</dc:creator>
      <dc:date>2020-01-24T04:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: need to dynamically call all available SDTM domain (including SUPP) names into a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/620072#M182145</link>
      <description>&lt;P&gt;The simplest solution is to modify the original macro so that it checks if the data exists, and exits if there are no data, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro combine(in=, out=, dst=);
  %if not %sysfunc(exist(&amp;amp;in.)) %then %do;
     %put Table &amp;amp;in not found;
     %return;
     %end;
  %if not %sysfunc(exist(supp&amp;amp;in.)) %then %do;
     %put Table SUPP&amp;amp;in not found;
     %return;
     %end;   
/* and the rest of the macro as before */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can just call the macro for all the domains, even if some of them do not exist:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%combine(in=dm, out=dm_merg);
%combine(in=se, out=se_merg);
%combine(in=sv, out=sv_merg);
%combine(in=ae, out=ae_merg);
%combine(in=ds, out=ds_merg);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Jan 2020 16:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/620072#M182145</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-01-26T16:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: need to dynamically call all available SDTM domain (including SUPP) names into a macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/620098#M182162</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169529"&gt;@ssv&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generate a list of all data set names where a supp domain name matches a parent domain name, then go through the names in the list in a loop. Sort of like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;                                                                                                                                                                                                                                              
  select memname into :supplist separated by " " from dictionary.tables where libname = "WORK" and memname not eqt "SUPP"                                                                                                                                       
  and    memname in (select substr (memname, 5)  from dictionary.tables where libname = "WORK" and memname     eqt "SUPP")                                                                                                                                      
  ;                                                                                                                                                                                                                                                             
quit ;                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                
%macro combine (list=, dst=) ;                                                                                                                                                                                                                                  
  %local i ;                                                                                                                                                                                                                                                    
  %do i = 1 %to sysfunc (countw (&amp;amp;list)) ;                                                                                                                                                                                                                      
    %let in = %scan (&amp;amp;list, &amp;amp;i) ;                                                                                                                                                                                                                               
    proc sort data = &amp;amp;in out = &amp;amp;in ;                                                                                                                                                                                                                            
      by usubjid &amp;amp;in.seq ;                                                                                                                                                                                                                                      
    run ;                                                                                                                                                                                                                                                       
    proc sort data = supp&amp;amp;in  out = supp&amp;amp;in ;                                                                                                                                                                                                                   
      by usubjid idvarval qnam ;                                                                                                                                                                                                                                
    run ;                                                                                                                                                                                                                                                       
    proc transpose data = supp&amp;amp;in out = supp&amp;amp;in._ (drop = _:) ;                                                                                                                                                                                                 
      by usubjid idvarval ;                                                                                                                                                                                                                                     
      id qnam ;                                                                                                                                                                                                                                                 
      idlabel qlabel ;                                                                                                                                                                                                                                          
      var qval ;                                                                                                                                                                                                                                                
    run ;                                                                                                                                                                                                                                                       
    data supp&amp;amp;in._ (drop = idvarval) ;                                                                                                                                                                                                                          
      set supp&amp;amp;in._ ;                                                                                                                                                                                                                                           
      &amp;amp;in.seq = input (idvarval, best.) ;                                                                                                                                                                                                                       
    run ;                                                                                                                                                                                                                                                       
    proc sort data = supp&amp;amp;in._ ;                                                                                                                                                                                                                                
      by usubjid &amp;amp;in.seq ;                                                                                                                                                                                                                                      
    run ;                                                                                                                                                                                                                                                       
    data &amp;amp;in._merg ;                                                                                                                                                                                                                                            
      merge &amp;amp;in (in = _in) supp&amp;amp;in._ ;                                                                                                                                                                                                                          
      by usubjid &amp;amp;in.seq ;                                                                                                                                                                                                                                      
      if _in ;                                                                                                                                                                                                                                                  
    run ;                                                                                                                                                                                                                                                       
  %end ;                                                                                                                                                                                                                                                        
%mend ;                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                
%combine (list=&amp;amp;supplist)             
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This way, you don't have to call the same macro a bunch of times and/or determine which domains to use as an argument by eyeballing your library. Leave this tedious and error-prone work to the computer - you're using it anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jan 2020 22:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-dynamically-call-all-available-SDTM-domain-including/m-p/620098#M182162</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2020-01-26T22:36:26Z</dc:date>
    </item>
  </channel>
</rss>

