<?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 auto create datasets names as macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60874#M13212</link>
    <description>Hi:&lt;BR /&gt;
  Several previous forum postings have discussed the use of DICTIONARY.TABLES and other types of DICTIONARY files in order to access information about SAS datasets. With PROC SQL, you can use the INTO clause in order to create macro variables from the results of a particular query. Some of the postings are:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=14535㣇" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=14535㣇&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=9171⏓" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=9171⏓&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=11252⯴" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=11252⯴&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Here are some user group papers that outline what the "dictionary" tables do:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/070-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/070-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/237-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/237-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.codecraftersinc.com/pdf/DictionaryTablesRefCard.pdf" target="_blank"&gt;http://www.codecraftersinc.com/pdf/DictionaryTablesRefCard.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf" target="_blank"&gt;http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.qsl.net/kd6ttl/sas/sqlutilov.pdf" target="_blank"&gt;http://www.qsl.net/kd6ttl/sas/sqlutilov.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
    <pubDate>Wed, 12 Nov 2008 15:38:44 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-11-12T15:38:44Z</dc:date>
    <item>
      <title>How to auto create datasets names as macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60873#M13211</link>
      <description>Hi there, &lt;BR /&gt;
&lt;BR /&gt;
I was wondering if anyone knows how to create a macro variable for all the members in a library.  I'm wanting to sort 30 datasets by a common variable and are considering using %do loop function, however would like to save time in typing the member names out in full. &lt;BR /&gt;
&lt;BR /&gt;
Cheers</description>
      <pubDate>Wed, 12 Nov 2008 15:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60873#M13211</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-12T15:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto create datasets names as macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60874#M13212</link>
      <description>Hi:&lt;BR /&gt;
  Several previous forum postings have discussed the use of DICTIONARY.TABLES and other types of DICTIONARY files in order to access information about SAS datasets. With PROC SQL, you can use the INTO clause in order to create macro variables from the results of a particular query. Some of the postings are:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=14535㣇" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=14535㣇&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=9171⏓" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=9171⏓&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=11252⯴" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=11252⯴&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Here are some user group papers that outline what the "dictionary" tables do:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/070-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/070-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/237-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/237-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.codecraftersinc.com/pdf/DictionaryTablesRefCard.pdf" target="_blank"&gt;http://www.codecraftersinc.com/pdf/DictionaryTablesRefCard.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf" target="_blank"&gt;http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.qsl.net/kd6ttl/sas/sqlutilov.pdf" target="_blank"&gt;http://www.qsl.net/kd6ttl/sas/sqlutilov.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 12 Nov 2008 15:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60874#M13212</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-11-12T15:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto create datasets names as macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60875#M13213</link>
      <description>Thanks for your prompt response Cynthia. &lt;BR /&gt;
I've not used Proc SQL before.  I'll try to work my way out through the threads you've provided.  &lt;BR /&gt;
&lt;BR /&gt;
Cheers</description>
      <pubDate>Wed, 12 Nov 2008 16:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60875#M13213</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-12T16:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto create datasets names as macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60876#M13214</link>
      <description>Hi:&lt;BR /&gt;
  You can certainly use CALL SYMPUT and DATA step to create your macro variables from the SASHELP views of the DICTIONARY tables. I believe some of the papers referenced show both methods.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 12 Nov 2008 18:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60876#M13214</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-11-12T18:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto create datasets names as macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60877#M13215</link>
      <description>I think this will work. &lt;BR /&gt;
&lt;BR /&gt;
libname xx "c:\test";&lt;BR /&gt;
&lt;BR /&gt;
data xx.a;&lt;BR /&gt;
   var1 = "testa";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data xx.b;&lt;BR /&gt;
   var2 = "testb";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select memname into :dataset_names separated by ' '&lt;BR /&gt;
   from dictionary.tables&lt;BR /&gt;
        where lowcase(libname) = 'xx';&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%put dataset_names = &amp;amp;dataset_names;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/* or you can use a data step */&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   set sashelp.vtable end=end;&lt;BR /&gt;
   where lowcase(libname) = 'xx';&lt;BR /&gt;
   length dataset_names $ 20;&lt;BR /&gt;
   retain dataset_names;&lt;BR /&gt;
   if _n_ = 1 then dataset_names = memname;&lt;BR /&gt;
   else dataset_names = strip(dataset_names) || ', ' || strip(memname) ;&lt;BR /&gt;
   if end then&lt;BR /&gt;
      do;&lt;BR /&gt;
         call symputx('dataset_names_2',dataset_names);&lt;BR /&gt;
      end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%put macro variable created by data step: &amp;amp;dataset_names_2;</description>
      <pubDate>Fri, 21 Nov 2008 20:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60877#M13215</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-21T20:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto create datasets names as macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60878#M13216</link>
      <description>call execute() in a data step might help[pre] data _null_ ;&lt;BR /&gt;
    set sashelp.vtable( where=( libname='YOURLIB' ));&lt;BR /&gt;
    call execute( 'proc sort data=yourlib.' !! memname );&lt;BR /&gt;
    call execute('   out= work.'!! memname ' );&lt;BR /&gt;
    call execute('    ; by BYVAR ; run; ' );&lt;BR /&gt;
run ;[/pre]&lt;BR /&gt;
I expect that solution is among those links Cynthia provided.&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Fri, 21 Nov 2008 22:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-auto-create-datasets-names-as-macro-variables/m-p/60878#M13216</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2008-11-21T22:31:11Z</dc:date>
    </item>
  </channel>
</rss>

