根据期限和间隔创建付款计划日期

时间:2015-10-21 20:55:49

标签: sas

我试图找到创建循环来推进约会的最佳方法。以下是我的数据的示例:

data example;
   format first_pmt_date mmddyys10.0;
   format schedule $25.;

   id=1;
   first_pmt_date="28JAN2011"d;
   schedule='Bi-Weekly';
   term=52;
   output;

   id=2;
   first_pmt_date="15JAN2011"d;
   schedule='Weekly';
   term=156;
   output;

   id=3;
   first_pmt_date="23JAN2011"d;
   schedule='Semi-Monthly';
   term=72;
   output;
run;

我想创建一个循环来根据付款方案(双周,半月,每周)推进first_pmt_date。例如,在上面的id 2的情况下,我有156行,所有付款日期从2011年1月15日开始每周推进。这是我正在寻找的一个例子:

id  first_pmt_date  schedule    term    scheduled_pmt_date
2   01/15/2011      Weekly      156     1/15/2011
2   01/15/2011      Weekly      156     1/22/2011
2   01/15/2011      Weekly      156     1/29/2011
2   01/15/2011      Weekly      156     2/5/2011
2   01/15/2011      Weekly      156     2/12/2011
2   01/15/2011      Weekly      156     2/19/2011

2 个答案:

答案 0 :(得分:1)

这个解决方案唯一奇怪的软糖是每两周我必须包括一个mod函数,在一周内增加3到4天的增量,以最后一个付款日期作为增量的基础。

我已经从0循环到TERM-1,这意味着您将使用SAS函数intnx获得正确数量的付款日期,以通过循环变量i增加日期。我已使用's'进行对齐,以确保所有付款与第一个付款变量保持一致。

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_help"
tools:context="com.abc.xyz.HelpActivity">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/optionIcon"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="16dp"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/option"
    android:layout_toRightOf="@+id/optionIcon"
    android:layout_alignParentTop="true"
    android:textSize="30sp"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/subOption"
    android:layout_toRightOf="@+id/optionIcon"
    android:layout_below="@+id/option"
    />

答案 1 :(得分:0)

半月刊有点含糊不清,除非你能提供一个你想要一个人如何表现的例子,否则你最好的办法是让一个整数循环计数器增加1并使用intnx函数将开始日期增加多个间隔。