<?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 Drop an entire array after using it in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408510#M12467</link>
    <description>&lt;P&gt;Good day. I have created a lag of all my variables and would like to drop the original variables and only keep the lagged variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code was used unsuccessfully:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array vars{*} _numeric_;
  array L1vars{1000};
  do i = 1 to dim(vars);
    L1vars{i} = lag(vars{i});
  end;
  drop i;
  drop vars;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Oct 2017 08:19:08 GMT</pubDate>
    <dc:creator>StephanDup</dc:creator>
    <dc:date>2017-10-30T08:19:08Z</dc:date>
    <item>
      <title>Drop an entire array after using it</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408510#M12467</link>
      <description>&lt;P&gt;Good day. I have created a lag of all my variables and would like to drop the original variables and only keep the lagged variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code was used unsuccessfully:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array vars{*} _numeric_;
  array L1vars{1000};
  do i = 1 to dim(vars);
    L1vars{i} = lag(vars{i});
  end;
  drop i;
  drop vars;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2017 08:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408510#M12467</guid>
      <dc:creator>StephanDup</dc:creator>
      <dc:date>2017-10-30T08:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Drop an entire array after using it</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408534#M12475</link>
      <description>&lt;P&gt;You can't drop arrays like that.&amp;nbsp; Arrays are only temporary references for groups of variables, not elements themselves.&amp;nbsp; You can of course pre-build the vars:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select distinct NAME
  into   :V separated by " "
  from   SASHELP.VCOLUMN
  where  LIBNAME="WORK"
    and  MEMNAME="HAVE"
    and  TYPE="num";
quit;&lt;/PRE&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; vars&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; &amp;amp;V.&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; L1vars&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  do i &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;dim&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;vars&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    L1vars&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;lag&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;vars&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt; i &amp;amp;V.&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 09:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408534#M12475</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-30T09:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Drop an entire array after using it</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408629#M12477</link>
      <description>&lt;PRE&gt;
Since your matrix refer to alll numeric variables. Try

drop _numeric_;

&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2017 12:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408629#M12477</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-30T12:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Drop an entire array after using it</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408642#M12478</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;gets partial credit here.&amp;nbsp; It's the right statement to add, but has to be added in exactly the right place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a DATA step, _numeric_ refers to all numeric variables that have been defined so far.&amp;nbsp; To get rid of the original numeric variables, the order of the statements must specifically be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array vars {*} _numeric_;&lt;/P&gt;
&lt;P&gt;drop _numeric_;&lt;/P&gt;
&lt;P&gt;array L1vars .........&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's the only point in your DATA step where _numeric_ refers to all the original numeric variables coming from HAVE.&amp;nbsp; (Yes, technically the DROP statement could come between the SET statement and the first ARRAY statement.)&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 13:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Drop-an-entire-array-after-using-it/m-p/408642#M12478</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-30T13:11:55Z</dc:date>
    </item>
  </channel>
</rss>

