English 中文(简体)
Computing Compounded Return in SAS
原标题:
  • 时间:2009-12-19 09:16:10
  •  标签:
  • sas

I have a dataset of date(monthly), person and return(monthly). I need to calculate the compounded monthly return of the dataset from April Year t to March Year t+1 for each person. For example,

Annual return Person A= April Year 1* May Year 1*......*March Year 2.

Can I know how can I do that in SAS? Do I need an array?

问题回答

Do you mean your dataset looks like

Date , Person , Return

"01Apr2009"d , A , 1.1

etc

etc

?

/* Then you can do */

data ur_input_data_view / view = ur_input_data_view;

  /* assuming your dataset is stored in ur_input_data */

  set ur_input_data;

  /* obtain the year and month from the date variable */

  year = year(date);

  mth = year(date);

run;

/* you can skip the sort if your data is already sorted by person then date */

proc sort data = ur_input_data;

  by person date;

run; 

data output_data;

  set ur_input_data_view ;

  by person date;

  /* reset annual return to null if looking at a new person or month is april */

  if first.person or mth = 4 then do;

    annual_return = return;

  end;

  retain annual_return;

  annual_return = annual_return * return;

  /* this will output nothing for the persons that don t have a record at march */

  if mth = 3 then output;

run;




相关问题
SAS stack overflow: PROC SQL reading dictionary.columns

I have a program in which I am reading dictionary.columns. There is a big program with lot of code before and after the program segment in which I read dictionary.column. The program used to work ...

SAS using encrypted (PWENCODE) in EMAILPW= option

My code works fine using plain text code, but fails when I use an encrypted password filename File email emailsys = VIM emailid= "&pa_usr" emailpw= "{sasenc}39AAD23E148A9555508AC84447181DFF" ; ...

How do I change the label in a data step header?

In SAS you can do. data a(rename=(a=b) ); a = 1; run; to rename a variable in the data step data statement (or data step header as I call it). What s the syntax to change the label? I tried ...

What s the easiest way to use SQLite with SAS?

I want to investigate how to access SQLite DB from SAS. What s the easiest way of doing this? Is there a SAS product that we can license to do that? I don t want to use ODBC drivers as that seems to ...

Computing Compounded Return in SAS

I have a dataset of date(monthly), person and return(monthly). I need to calculate the compounded monthly return of the dataset from April Year t to March Year t+1 for each person. For example, ...

Exchange Server and SAS 9.1.3/9.2

has anyone successfully interacted with a microsoft exchange server in SAS 9.1.3 or 9.2? i know it can be done with SAS Ent. Guide 4.x, but i m not interested in that route if regular SAS can do it.

Logging SAS scripts

I ve been developing a lot of Java, PHP and Python. All of which offer great logging packages (Log4J, Log or logging respectively). This is a great help when debugging applications. Especially if the ...

热门标签