BookmarkSubscribeRSS Feed
brandonepena931
Calcite | Level 5

I'm trying to do some calculations with a data set like the one below:

 

Item_Set_1         Item_Set_2         Value         Calculation

   xyz                                                  1

  aaa                                                  2

 bbb                                                   3

                            ccc                        4

                            ddd                       5

                            eee                       6

 

 

I want to do it so that I take the corresponding value to Item_Set_1 and multiply by the corresponding value to Item_Set_2. Any easy way to do this?

 

5 REPLIES 5
Shmuel
Garnet | Level 18

data want;

  set have;

        retain prev_value;

        prev_value = lag(value);

        if _N_ > 1 then calculation = value * prev_value;

run;

brandonepena931
Calcite | Level 5
Sorry, my dataset is quite a bit large and doesn't follow the exact pattern as shown above. It's a bit more random
brandonepena931
Calcite | Level 5

Apologies for that. See the example below for something a bit more accurate.
Time                Item_Set_1            Item_Set_2         Value          Calculation

period1                   xyz                                                 1

period2                 aaa                                                   2

period3                bbb                                                    3

period4                                         ccc                            4

period5                                        ddd                            5

period6                                        eee                             6

nrk1787db1
Obsidian | Level 7

Writing detailed requirement with examples will help people trying to understand the problems you are facing and help you out.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 941 views
  • 0 likes
  • 4 in conversation