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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1438 views
  • 0 likes
  • 4 in conversation