<?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: Keeping, dropping, renaming variables without knowing their names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103293#M291242</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can retrieve the column names (based on their "physical" position) by using ds functions such as open and varname.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Aug 2013 08:26:49 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2013-08-07T08:26:49Z</dc:date>
    <item>
      <title>Keeping, dropping, renaming variables without knowing their names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103291#M291240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to write some generic code for use in a macro which includes the capability to keep, drop and rename variables, but knowing only the variable's &lt;EM&gt;position&lt;/EM&gt; in the dataset, not its name. For instance, how do I drop the second variable (column) in a dataset without knowing its name?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 07:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103291#M291240</guid>
      <dc:creator>ChrisCHPT</dc:creator>
      <dc:date>2013-08-07T07:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping, dropping, renaming variables without knowing their names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103292#M291241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The physical ordering in SAS-data or any table (external table) is not determined.&lt;/P&gt;&lt;P&gt;The position is not really defined, what is your real issue you are trying to solve? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 07:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103292#M291241</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-07T07:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping, dropping, renaming variables without knowing their names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103293#M291242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can retrieve the column names (based on their "physical" position) by using ds functions such as open and varname.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 08:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103293#M291242</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-08-07T08:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping, dropping, renaming variables without knowing their names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103294#M291243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could do something like the following.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET DSID&amp;nbsp; = %SYSFUNC(OPEN(SASHELP.CLASS,I));&lt;/P&gt;&lt;P&gt;%LET DROP&amp;nbsp; = %SYSFUNC(VARNAME(&amp;amp;DSID,2)); &lt;/P&gt;&lt;P&gt;%LET CLOSE = CLOSE(&amp;amp;DSID.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%PUT **********&amp;amp;DROP.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This produces the name of the second variable (specified by the second argument in the VARNAME statement) in your dataset.&amp;nbsp; I am sure you know how to make this function for multiple variables you wish to drop and how to incorporate it into your existing code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 08:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103294#M291243</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-08-07T08:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping, dropping, renaming variables without knowing their names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103295#M291244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dictionary.Columns accessible with Proc SQL contains the descriptions of columns in the datasets in your libraries. You could retrieve the varaible name using something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select name into: dropname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns where libname='WORK' and memname='DATASETNAME' and&lt;/P&gt;&lt;P&gt;varnum = &amp;lt;column number value goes here&amp;gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;Note that case for libname and memname must be in upper case as that is how the information is&amp;nbsp; stored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then use the macro variable value &amp;amp;dropname in any statement you need.&lt;/P&gt;&lt;P&gt;If you want a space delimited list then modify the above&lt;/P&gt;&lt;P&gt; select name into : dropname separated by ' '&lt;/P&gt;&lt;P&gt; and varnum in (&amp;lt;list of column numbers&amp;gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 21:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103295#M291244</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-08-07T21:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping, dropping, renaming variables without knowing their names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103296#M291245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://www.lexjansen.com/wuss/2006/data_presentation_and_business_intelligence/DPR-Choate.pdf" title="http://www.lexjansen.com/wuss/2006/data_presentation_and_business_intelligence/DPR-Choate.pdf"&gt;http://www.lexjansen.com/wuss/2006/data_presentation_and_business_intelligence/DPR-Choate.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I never found a good reason (some exceptions) why the order of variables would be important. See PDV reference. &lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p18vk5t9cwort1n18g7zg2no6tr4.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p18vk5t9cwort1n18g7zg2no6tr4.htm"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/A&gt; and &lt;A href="http://support.sas.com/resources/papers/proceedings12/255-2012.pdf" title="http://support.sas.com/resources/papers/proceedings12/255-2012.pdf"&gt;http://support.sas.com/resources/papers/proceedings12/255-2012.pdf&lt;/A&gt;&lt;BR /&gt;Unless some thinking habits are taken from some other tool like Excel, I don not understand this type of questions needing some order position number of a variable when you aree starting to use SAS. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 06:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-dropping-renaming-variables-without-knowing-their-names/m-p/103296#M291245</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-08T06:17:29Z</dc:date>
    </item>
  </channel>
</rss>

