<?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: Decrement date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83619#M18049</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;This assumes that your variables are in a sequential order.&amp;nbsp; I used week.3 because you mentioned the specific dates &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;01JUL2013 24JUN2013 17JUN2013.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%LET FIRSTMTH = DT_%SYSFUNC(PUTN(%SYSFUNC(INTNX(WEEK.3,%SYSFUNC(TODAY()),-36,END)),DATE9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%LET LASTMTH&amp;nbsp; = DT_%SYSFUNC(PUTN(%SYSFUNC(INTNX(WEEK.3,%SYSFUNC(TODAY()),-1,END)),DATE9.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET HAVE (KEEP = ID &amp;amp;FIRSTMTH. -- &amp;amp;LASTMTH.);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Jul 2013 08:03:57 GMT</pubDate>
    <dc:creator>Scott_Mitchell</dc:creator>
    <dc:date>2013-07-19T08:03:57Z</dc:date>
    <item>
      <title>Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83613#M18043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; There is a dataset that has date columns from Jul1,2013 to Dec1,2011.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Every week I need to process data taking last 36 weeks starting from the current date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; How to use this in a&amp;nbsp; loop to use in a put statement to output it to a text file alsong with Id .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e put @01 id&amp;nbsp; dt_01JUL2013 dt_24JUN2013 dt_17Jun2013?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 15:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83613#M18043</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-07-18T15:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83614#M18044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you are asking:&lt;/P&gt;&lt;P&gt;I have a dataset with varying colum-names (dt_&amp;amp;&amp;amp;date&amp;amp;i) wanting in put statement than:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define an array in the datastep to process all columns.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/65040/HTML/default/viewer.htm#n00gp8yc3x6rcgn1la2w81ru9lb6.htm" title="http://support.sas.com/documentation/cdl/en/lestmtsref/65040/HTML/default/viewer.htm#n00gp8yc3x6rcgn1la2w81ru9lb6.htm"&gt;SAS(R) 9.4 Statements: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variability of all the dates can be solved by first defining macro variables with the names.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 20:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83614#M18044</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-07-18T20:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83615#M18045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are your columns called, exactly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83615#M18045</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-18T21:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83616#M18046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Date columns are: dt_01Jun2013&amp;nbsp;&amp;nbsp;&amp;nbsp; dt_24Jun2013&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83616#M18046</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-07-18T21:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83617#M18047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a bad way to store information, but probably besides the point now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you need to provide more info on your data structure. For example, if it is weekly data the 1st of June is a Saturday, but the 24 is a monday, so how are the columns names determined. I'm assuming you'd need to dynamically generate the columns you'd need to pull. Do you have to do a data step with put or can you use a proc export or tagset to export?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="2263" __jive_macro_name="document" class="jive_macro jive_macro_document" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 00:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83617#M18047</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-07-19T00:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83618#M18048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with Reeza about your data structure, but anyway, here is how to get what you want, or something close to it :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;select name into :keepCols separated by ","&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from dictionary.columns&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;where libname="WORK" and memname="MYTEST" and&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;input(substr(name,4),? anydtdte9.) &amp;gt;= intnx("WEEK", today(), -36, "S");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;create table keep36weeks as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;select id, &amp;amp;keepCols from mytest;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 01:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83618#M18048</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-19T01:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Decrement date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83619#M18049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;This assumes that your variables are in a sequential order.&amp;nbsp; I used week.3 because you mentioned the specific dates &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;01JUL2013 24JUN2013 17JUN2013.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%LET FIRSTMTH = DT_%SYSFUNC(PUTN(%SYSFUNC(INTNX(WEEK.3,%SYSFUNC(TODAY()),-36,END)),DATE9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%LET LASTMTH&amp;nbsp; = DT_%SYSFUNC(PUTN(%SYSFUNC(INTNX(WEEK.3,%SYSFUNC(TODAY()),-1,END)),DATE9.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET HAVE (KEEP = ID &amp;amp;FIRSTMTH. -- &amp;amp;LASTMTH.);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 08:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decrement-date/m-p/83619#M18049</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-07-19T08:03:57Z</dc:date>
    </item>
  </channel>
</rss>

