<?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: Dropping rolling fields off monthly dataset? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6432#M2522</link>
    <description>Thank you 1162 and Peter - that is very helpful!&lt;BR /&gt;
&lt;BR /&gt;
I went with 1162's way due to me seeing it first, but appreciate the help!&lt;BR /&gt;
-=James</description>
    <pubDate>Tue, 22 Jan 2008 18:04:49 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-01-22T18:04:49Z</dc:date>
    <item>
      <title>Dropping rolling fields off monthly dataset?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6429#M2519</link>
      <description>It has to be Friday before a three day weekend, because I am completely drawing a blank on this -- It should be relatively easy to do, but I'm not seeing it...&lt;BR /&gt;
&lt;BR /&gt;
Say I have a dataset that looks like this last month:&lt;BR /&gt;
&lt;BR /&gt;
DATA SUBSET;                                         &lt;BR /&gt;
.....     &lt;BR /&gt;
FX200601='xxxx'; FX200701='xxxx'; &lt;BR /&gt;
FX200602='xxxx'; FX200702='xxxx';                    &lt;BR /&gt;
FX200603='xxxx'; FX200703='xxxx';                    &lt;BR /&gt;
FX200604='xxxx'; FX200704='xxxx';                    &lt;BR /&gt;
FX200605='xxxx'; FX200705='xxxx';                    &lt;BR /&gt;
FX200606='xxxx'; FX200706='xxxx';                    &lt;BR /&gt;
FX200608='xxxx'; FX200708='xxxx';                    &lt;BR /&gt;
FX200609='xxxx'; FX200709='xxxx';                    &lt;BR /&gt;
FX200610='xxxx'; FX200710='xxxx';                    &lt;BR /&gt;
FX200611='xxxx'; FX200711='xxxx';                    &lt;BR /&gt;
FX200612='xxxx'; FX200712='xxxx';                    &lt;BR /&gt;
&lt;BR /&gt;
This month, new field FX200801='xxxx' will be added to the dataset, but I want to delete off the 25th prior field (FX200601)..  In essence I only want the last 24 occurances..  The field names will always have the 4 digit year and month in the name.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas on how to do this the quickest &amp;amp; easiest way?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
-=James</description>
      <pubDate>Fri, 18 Jan 2008 18:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6429#M2519</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-18T18:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping rolling fields off monthly dataset?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6430#M2520</link>
      <description>I don't know if this is the quickest or easiest, but I'll take a shot . . .&lt;BR /&gt;
&lt;BR /&gt;
These look like variables (i.e. columns) in a dataset.  I would consider using PROC CONTENTS to get a list of the variable names.  Filter this list to get the variables that start with 'FX200%'.  Then sort descending and put the first 24 occurrences into a macro variable.  You can use this macro variable to reference the 24 most recent columns.&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
DATA SUBSET;&lt;BR /&gt;
FX200601='xxxx'; FX200701='xxxx'; FX200801='xxxx';&lt;BR /&gt;
FX200602='xxxx'; FX200702='xxxx';&lt;BR /&gt;
FX200603='xxxx'; FX200703='xxxx';&lt;BR /&gt;
FX200604='xxxx'; FX200704='xxxx';&lt;BR /&gt;
FX200605='xxxx'; FX200705='xxxx';&lt;BR /&gt;
FX200606='xxxx'; FX200706='xxxx';&lt;BR /&gt;
FX200607='xxxx'; FX200707='xxxx';&lt;BR /&gt;
FX200608='xxxx'; FX200708='xxxx';&lt;BR /&gt;
FX200609='xxxx'; FX200709='xxxx';&lt;BR /&gt;
FX200610='xxxx'; FX200710='xxxx';&lt;BR /&gt;
FX200611='xxxx'; FX200711='xxxx';&lt;BR /&gt;
FX200612='xxxx'; FX200712='xxxx'; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc contents data=subset out=contents noprint;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=contents (keep=NAME where=(name like 'FX200%')); by descending name; run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
	select name into :varlist separated by " "&lt;BR /&gt;
	from contents (obs=24);&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data newset;&lt;BR /&gt;
	set subset (keep=&amp;amp;varlist);&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 18 Jan 2008 22:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6430#M2520</guid>
      <dc:creator>1162</dc:creator>
      <dc:date>2008-01-18T22:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping rolling fields off monthly dataset?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6431#M2521</link>
      <description>just another way ...&lt;BR /&gt;
since "latest" is defined as the one to add, and the one to remove is two years before, a small amount of work with macro variables should reduce the issue....&lt;BR /&gt;
(assuming latest is last month)[pre]&lt;BR /&gt;
%let latest = %sysfunc( intnx( month, "&amp;amp;sysdate9"d, -1), yymmN6 );&lt;BR /&gt;
%let remove = %sysfunc( intnx( month, "&amp;amp;sysdate9"d, -25), yymmN6 ); [/pre]&lt;BR /&gt;
Write code so that the new column are added "after" existing columns, then the data steps can use an array statement to refer to the whole picture. [pre]&lt;BR /&gt;
option symbolgen ;&lt;BR /&gt;
data new_data_set ;&lt;BR /&gt;
 set old_data_set( drop= FX&amp;amp;remove );&lt;BR /&gt;
  fx&amp;amp;latest = ....some formula... ;&lt;BR /&gt;
  array fxs(24) fx: ; *all columns beginning FX;&lt;BR /&gt;
          *avoid unwanted columns having the FX prefix;&lt;BR /&gt;
  rolling_mean24 = mean( of fxs(*) );&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Good Luck&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Mon, 21 Jan 2008 15:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6431#M2521</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-21T15:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping rolling fields off monthly dataset?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6432#M2522</link>
      <description>Thank you 1162 and Peter - that is very helpful!&lt;BR /&gt;
&lt;BR /&gt;
I went with 1162's way due to me seeing it first, but appreciate the help!&lt;BR /&gt;
-=James</description>
      <pubDate>Tue, 22 Jan 2008 18:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dropping-rolling-fields-off-monthly-dataset/m-p/6432#M2522</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-22T18:04:49Z</dc:date>
    </item>
  </channel>
</rss>

