<?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: List of Most Recent Created Variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191620#M48201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response. Correct. I'm using SET statement on a dataset that has a large number of variables to create a new dataset with even larger number of variables created using a macro based on certain naming criteria I'm implementing. I was interested in retrieving the variable names that were created the last.&lt;/P&gt;&lt;P&gt;I was using the naive approach below but was wondering if there is a smarter way...!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..... macro to create large number of variables;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql number;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select name , label&lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp; where lowcase(Libname)='work' and lowcase(memname)='X'&lt;/P&gt;&lt;P&gt;&amp;nbsp; and name not in &lt;/P&gt;&lt;P&gt;&amp;nbsp; (select name from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp; where lowcase(Libname)='work' and lowcase(memname)='Y');&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Mar 2014 00:41:50 GMT</pubDate>
    <dc:creator>Altal</dc:creator>
    <dc:date>2014-03-03T00:41:50Z</dc:date>
    <item>
      <title>List of Most Recent Created Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191618#M48199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know a way in proc content or SQL to get a list of the "most recent variables created in the last data step"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a big data set with large number of variables, and I'm interested to retrieve names of variables created in the last data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Mar 2014 16:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191618#M48199</guid>
      <dc:creator>Altal</dc:creator>
      <dc:date>2014-03-02T16:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: List of Most Recent Created Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191619#M48200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That doesn't really make any sense. When you create a data set you create ALL of the variables for that data set. Even if some of them are coming from the inputs.&amp;nbsp; The order of the variables will be determined by the order that the compiler notices the variables, not whether the step has made any modification to the values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To see the most recently created data set you can use the &amp;amp;SYSLAST macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data=&amp;amp;syslast varnum ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Mar 2014 17:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191619#M48200</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-02T17:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: List of Most Recent Created Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191620#M48201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response. Correct. I'm using SET statement on a dataset that has a large number of variables to create a new dataset with even larger number of variables created using a macro based on certain naming criteria I'm implementing. I was interested in retrieving the variable names that were created the last.&lt;/P&gt;&lt;P&gt;I was using the naive approach below but was wondering if there is a smarter way...!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..... macro to create large number of variables;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql number;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select name , label&lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp; where lowcase(Libname)='work' and lowcase(memname)='X'&lt;/P&gt;&lt;P&gt;&amp;nbsp; and name not in &lt;/P&gt;&lt;P&gt;&amp;nbsp; (select name from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp; where lowcase(Libname)='work' and lowcase(memname)='Y');&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 00:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191620#M48201</guid>
      <dc:creator>Altal</dc:creator>
      <dc:date>2014-03-03T00:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: List of Most Recent Created Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191621#M48202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your approach makes sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the number of libraries/datasets gets bigs, the performance of disctionary.columns can get slow.&amp;nbsp; If that happens, could be faster to just run PROC CONTENTS on both datasets to make OUT= datasets with the variable names, and then compare those.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't tried it, but it's possible you could get PROC COMPARE to do the work for you.&amp;nbsp; If you run:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC COMPARE base=x (obs=0) compare=y (obs=0);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder if it would still compare the metadata?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 03:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191621#M48202</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-03-03T03:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: List of Most Recent Created Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191622#M48203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works. Add the LISTALL option to get the variables to list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt; set sashelp.class ;&lt;/P&gt;&lt;P&gt; teen = age &amp;gt; 12;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc compare data=class(obs=0) compare=sashelp.class(obs=0) listall;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 14:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191622#M48203</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-03T14:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: List of Most Recent Created Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191623#M48204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your responses!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 14:25:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/List-of-Most-Recent-Created-Variables/m-p/191623#M48204</guid>
      <dc:creator>Altal</dc:creator>
      <dc:date>2014-03-03T14:25:34Z</dc:date>
    </item>
  </channel>
</rss>

