I put some data below, but I have a question about making a varialbe that is it's value minus the value of the last month. I have a variable activemonth_final that is in the format 2020m1, 2020m2, 2020m3, etc. The variable ccda_all_act_ind has a different value for each month. Is there a way I can make a variable that shows ccda_all_act_ind minus it's value from last month? For example, in the 2020m1 case it would show 2020m1-2019m12. Thanks!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(activemonth_final ccda_all_act_ind) 611 . 647 2206 587 . 671 2486 659 2241 623 . 719 3084 695 2970 599 . 707 3079 683 2793 635 . 684 2875 708 3209 672 2517 612 . 588 . 720 3213 660 2230 624 . 636 2077 696 3160 600 . 648 2178 697 3160 721 3200 649 2196 685 2816 613 . 589 . 709 3147 661 2213 625 . 637 2047 673 2658 601 . 710 3178 638 2182 650 2297 686 2980 698 3226 602 . 674 2746 626 . 614 . 494 . 662 2250 590 . 722 3195 615 . 663 2231 627 . 603 . 699 3198 639 2299 579 . 723 2941 675 2637 711 3182 591 . 651 2256 687 2917 712 3172 652 2230 676 2743 700 3215 616 . 724 2973 628 . 688 2990 604 . 640 2295 592 . 664 2227 677 2699 701 3126 689 3067 629 . 593 . 725 3051 617 . 641 2231 653 2194 713 3051 665 2299 605 . 642 2276 678 2672 594 . 654 2231 702 3076 630 . 606 . 666 2349 726 2983 690 2981 714 3180 582 . 618 . 703 3147 end format %tm activemonth_final
Listed 100 out of 152 observations
Use the count() option to list more
.
0 Response to Create a Variable in stata that is a value minus it's last month value
Post a Comment