DATA Step, Macro, Functions and more

How do I calculate a variance from record to record in one dataset?

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

How do I calculate a variance from record to record in one dataset?

If I have a dataset as follows:

 

Date.    Profit

Jan 1.    $100

Jan 2.     $200

Jan 3.    $150

 

How can I calculate the daily change in profit, so that the new data set is as follows:

 

Date. Profit  Variance-from-prior-day
Jan 1. $100.    .
Jan 2. $200.    $100
Jan 3. $150.    -$50

 

Thanks!!


Accepted Solutions
Solution
‎03-07-2016 02:30 PM
Super User
Posts: 17,937

Re: How do I calculate a variance from record to record in one dataset?

The DIF() function.

Var=dif(profit);

View solution in original post


All Replies
Solution
‎03-07-2016 02:30 PM
Super User
Posts: 17,937

Re: How do I calculate a variance from record to record in one dataset?

The DIF() function.

Var=dif(profit);
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 157 views
  • 0 likes
  • 2 in conversation